Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define _USE_MATH_DEFINES in joint_soft_limiter.cpp to ensure that M_PI is defined #2001

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

traversaro
Copy link
Contributor

@traversaro traversaro commented Jan 13, 2025

joint_soft_limiter.cpp uses M_PI, that on Windows is defined by cmath only if the _USE_MATH_DEFINES macro is defined prior to the first inclusion of cmath.

fyi @GilmarCorreia

To send us a pull request, please:

  • Fork the repository.
  • Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
  • Ensure local tests pass. (colcon test and pre-commit run (requires you to install pre-commit by pip3 install pre-commit)
  • Commit to your fork using clear commit messages.
  • Send a pull request, answering any default questions in the pull request interface.
  • Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

…I is defined

`joint_soft_limiter.cpp` uses `M_PI`, that on Windows is defined by `cmath` only if the `_USE_MATH_DEFINES` macro is defined prior to the first inclusion of cmath.
Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Why not just add that as compile_definitions in the CMakeLists?

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.28%. Comparing base (00c7088) to head (b317408).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2001      +/-   ##
==========================================
- Coverage   89.29%   89.28%   -0.02%     
==========================================
  Files         130      130              
  Lines       14523    14526       +3     
  Branches     1258     1258              
==========================================
  Hits        12969    12969              
- Misses       1085     1089       +4     
+ Partials      469      468       -1     
Flag Coverage Δ
unittests 89.28% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
joint_limits/src/joint_soft_limiter.cpp 87.59% <ø> (ø)

... and 4 files with indirect coverage changes

@traversaro
Copy link
Contributor Author

traversaro commented Jan 14, 2025

Thanks for the fix. Why not just add that as compile_definitions in the CMakeLists?

That's also an option. If the use of M_PI is really local I typically prefer to define _USE_MATH_DEFINES in the code so it works regardless of the build system used to compile the code, but in this specific case I really think that it would be strange if someone builds this specific code on Windows/MSVC without using CMake, so it really the same. If you prefer I can change it to a CMake compile definition.

@bmagyar
Copy link
Member

bmagyar commented Jan 15, 2025

I also prefer it in the file, so we know where it is needed.

@bmagyar bmagyar merged commit 751cd85 into ros-controls:master Jan 15, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants