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

M_PI is non-standard #3

Closed
eXpl0it3r opened this issue Apr 13, 2021 · 3 comments
Closed

M_PI is non-standard #3

eXpl0it3r opened this issue Apr 13, 2021 · 3 comments

Comments

@eXpl0it3r
Copy link

You're using M_PI in parts of the code, unfortunately this constant isn't really defined in the standard and while available in most compilers, some compilers, like MSVC require additional steps to use it.
On top of that, since you use M_PI in a header file, the library user now also has to deal with it in their codebase.

Steps to Reproduce

Build Candle with MSVC (2019)

Actual Behavior

RadialLight.cpp(24,22): error C2065: 'M_PI': undeclared identifier
Line.cpp(14,30): error C2065: 'M_PI': undeclared identifier
Line.cpp(15,43): error C2065: 'M_PI': undeclared identifier
Line.cpp(15,56): error C2065: 'M_PI': undeclared identifier
Line.cpp(17,20): error C2065: 'M_PI': undeclared identifier

Expected Behavior

Candle builds without errors

Solutions

  • You could add add_definition(-D_USE_MATH_DEFINES) to your CMake file in a scope for MSVC
  • Add #define _USE_MATH_DEFINES in front of every <cmath> include
  • Use a custom constant for PI
@MiguelMJ
Copy link
Owner

Thanks for pointing it out! I appreciate it so much.

@MiguelMJ
Copy link
Owner

@all-contributors please add @eXpl0it3r for bug

@allcontributors
Copy link
Contributor

@MiguelMJ

I've put up a pull request to add @eXpl0it3r! 🎉

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

No branches or pull requests

2 participants