Sample program shows that M_PI_2 is available on Linux because of _GNU_SOURCE macros defined by g++ for "systems using glibc".
MinGW does not define _GNU_SOURCE, but OCCT compiles fine because of usage of "-std=gnu++0x" compiler flag instead of "-std=c++0x".
This activates GNU extensions and undefines __STRICT_ANSI__ macros.
So that as alternative you may defined C++ standard version/extensions to MinGW consistent to how OCCT was built itself.
I've replaced my app previous flag c++17 by -std=gnu++0x; this indeed defines M_PI_2 without the need of -D_USE_MATH_DEFINES .
But, if you're using smart pointers with the syntax std::make_unique< , this seems conflicting with the -std=gnu++0x flag.
So, it's probably better just to add the -D_USE_MATH_DEFINES flag in your app compiler options.
Author
07Commenter-1
-std=gnu++0x means C++0x (enabled by -std=c++0x) with GNU extensions, which was added to GCC before C++11 standard has been actually released.
This is a minimal requirement for building OCCT, but you can use a higher version if you like with -std=gnu++17 or something like this.
08Author
I've already tried the option -std=gnu++17.
It doesn't work ( M_PI_2 not defined) without the -D_USE_MATH_DEFINES flag.
But it's really no trouble at all to add -D_USE_MATH_DEFINES in apps compiling options.
Author
09Commenter-1
Well, it is an unexpected behavior. g++ (tdm64-1) 5.1.0 works as expected with -std=gnu++17 flag.
Probably they have changed something in newer versions...