Skip to content

Conversation

@traversaro
Copy link
Contributor

@traversaro traversaro commented Feb 12, 2025

The PR #34 fixed the use of angles in some downstream compilation units, but not in all of them. The problem is that in this project M_PI is used in a public header, so just adding #define _USE_MATH_DEFINES in the header works if a compilation unit uses this header as:

#include <angles/angles.h>

#include <cmath>

but will fail if it is used as:

#include <cmath>

#include <angles/angles.h>

as in the second case, _USE_MATH_DEFINES is defined once math.h was already included, and so it is not possible to "retroactively" set it.

To ensure that _USE_MATH_DEFINES is always defined, we set it via CMake. I also left the _USE_MATH_DEFINES defined in the code to avoid breaking downstream consumers that do not use CMake, but I wrapped it with #ifndef _USE_MATH_DEFINES to avoid warnings.

@DLu DLu merged commit 633d83e into ros:ros2 Feb 19, 2025
2 checks passed
@traversaro
Copy link
Contributor Author

Thanks @DLu !

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.

2 participants