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

crossplattform: enable math constants on all plattforms #218

Merged
merged 2 commits into from
Feb 12, 2015

Conversation

TheJJ
Copy link
Member

@TheJJ TheJJ commented Feb 7, 2015

This introduces namespaced math constants available on all plattforms.

closes #208.

@TheJJ TheJJ force-pushed the math-constants branch 2 times, most recently from a839a4d to b75daec Compare February 7, 2015 17:35
@TheJJ TheJJ added lang: c++ Done in C++ code code quality Does not alter behavior, but beauty of our code labels Feb 7, 2015
@franciscod
Copy link
Contributor

boooo 👎

In file included from C:/msys/home/Windows/openage/cpp/unit/unit.cpp:8:0:
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:13:33: e                                                      rror: 'M_E' was not declared in this scope
 constexpr double E            = M_E;        //!< e
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:14:33: e                                                      rror: 'M_LOG2E' was not declared in this scope
 constexpr double LOG2E        = M_LOG2E;    //!< log_2 e
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:15:33: e                                                      rror: 'M_LOG10E' was not declared in this scope
 constexpr double LOG10E       = M_LOG10E;   //!< log_10 e
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:16:33: e                                                      rror: 'M_LN2' was not declared in this scope
 constexpr double LN2          = M_LN2;      //!< log_e 2
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:17:33: e                                                      rror: 'M_LN10' was not declared in this scope
 constexpr double LN10         = M_LN10;     //!< log_e 10
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:18:33: e                                                      rror: 'M_PI' was not declared in this scope
 constexpr double PI           = M_PI;       //!< pi
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:19:33: e                                                      rror: 'M_PI_2' was not declared in this scope
 constexpr double PI_2         = M_PI_2;     //!< pi/2
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:20:33: e                                                      rror: 'M_PI_4' was not declared in this scope
 constexpr double PI_4         = M_PI_4;     //!< pi/4
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:21:33: e                                                      rror: 'M_1_PI' was not declared in this scope
 constexpr double INV_PI       = M_1_PI;     //!< 1/pi
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:22:33: e                                                      rror: 'M_2_PI' was not declared in this scope
 constexpr double INV2_PI      = M_2_PI;     //!< 2/pi
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:23:33: e                                                      rror: 'M_2_SQRTPI' was not declared in this scope
 constexpr double INV2_SQRT_PI = M_2_SQRTPI; //!< 2/sqrt(pi)
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:24:33: e                                                      rror: 'M_SQRT2' was not declared in this scope
 constexpr double SQRT_2       = M_SQRT2;    //!< sqrt(2)
                                 ^
C:/msys/home/Windows/openage/cpp/unit/../crossplatform/math_constants.h:25:33: e                                                      rror: 'M_SQRT1_2' was not declared in this scope
 constexpr double INV_SQRT_2   = M_SQRT1_2;  //!< 1/sqrt(2)
                                 ^
C:/msys/home/Windows/openage/cpp/unit/unit.cpp: In function 'unsigned int openag                                                      e::dir_group(openage::coord::phys3_delta, unsigned int, unsigned int)':
C:/msys/home/Windows/openage/cpp/unit/unit.cpp:160:1: warning: control reaches e                                                      nd of non-void function [-Wreturn-type]
 }
 ^
cpp/CMakeFiles/openage.dir/build.make:1388: recipe for target 'cpp/CMakeFiles/op                                                      enage.dir/unit/unit.cpp.obj' failed
make[2]: *** [cpp/CMakeFiles/openage.dir/unit/unit.cpp.obj] Error 1
CMakeFiles/Makefile2:1108: recipe for target 'cpp/CMakeFiles/openage.dir/all' fa                                                      iled
make[1]: *** [cpp/CMakeFiles/openage.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

@franciscod
Copy link
Contributor

see the previous comment. I think it breaks (on msys) because cmath gets imported earlier in the build process without the _USE_MATH_DEFINES macro defined.

however, on linux it builds fine, lol

i'm poor man's travis

@TheJJ
Copy link
Member Author

TheJJ commented Feb 7, 2015

Hmm, but then i see no other solution than defining the constants manually to the actual numbers.

We can't manipulate the inclusion order and devs will want to include <cmath> without thinking about breaking the constant definitions..

@franciscod
Copy link
Contributor

These guys were defining that macro on CMakeLists, but since then migrated too boost:

ddemidov/vexcl@696d74a


The math library normally defines M_PI to a double approximation of pi. If strict ISO and/or POSIX >compliance are requested this constant is not defined, but you can easily define it yourself:

#define M_PI 3.14159265358979323846264338327
You can also compute the value of pi with the expression acos (-1.0).

http://www.sbin.org/doc/glibc/libc_19.html


My vote goes to hardcode the constants without relying on the cmath behaviour.

@franciscod
Copy link
Contributor

TheJJ#1

yo

@franciscod
Copy link
Contributor

typo on crossplattform!

@TheJJ
Copy link
Member Author

TheJJ commented Feb 8, 2015

oh lol 👊

but the idea of pullrequesting at forks is pretty good actually

@TheJJ TheJJ force-pushed the math-constants branch 3 times, most recently from 88757bd to 2a0b71a Compare February 8, 2015 00:51
@franciscod
Copy link
Contributor

builds fine on msys2 now, 👍

@franciscod
Copy link
Contributor

half typos remaining!

crossplatform: namespaced math constants on all plattforms
        ^                                          ^
        |                                          |-NOT OK
        |-OK                                          

not a big issue... you can decide how nazi is our grammar policy :D

@andrekupka
Copy link
Member

👍

andrekupka pushed a commit that referenced this pull request Feb 12, 2015
crossplattform: enable math constants on all plattforms
@andrekupka andrekupka merged commit b3fcf06 into SFTtech:master Feb 12, 2015
@TheJJ TheJJ deleted the math-constants branch February 12, 2015 16:03
bombadie pushed a commit to bombadie/openage that referenced this pull request Mar 11, 2016
gentlemen let's honor SFTtech#218 pls

to be squashed: forgot about the import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Does not alter behavior, but beauty of our code lang: c++ Done in C++ code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants