MADEAPPS / newton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.
http://www.newtondynamics.com
Other
928 stars 183 forks source link

4.02 EM_INVALID not defined when building MinGW-w64 #307

Closed brechtsanders closed 1 year ago

brechtsanders commented 1 year ago

I was trying to build version 4.02 on Windows using MinGW-w64 and got errors that EM_INVALID is not defined.

It looks like it is referenced in sdk/dCore/ndUtils.h:

    #if defined (WIN32) || defined(_WIN32)
        #define D_FLOAT_EXCEPTIONS_MASK (EM_INVALID | EM_DENORMAL)
    #else
        #define D_FLOAT_EXCEPTIONS_MASK (FE_INVALID | FE_INEXACT)
    #endif

The problem is the #if line assumes Windows builds are always done with MSVC.

Changing that line like this allows the build to continue:

    #if (defined (WIN32) || defined(_WIN32)) && !defined(__MINGW32__)

But you may want to change it to checking something more MSVC specific.

JulioJerez commented 1 year ago

fixed, thanks I made like this

//#if defined (WIN32) || defined(_WIN32)
#if defined (_MSC_VER)
    #define D_FLOAT_EXCEPTIONS_MASK (_EM_ZERODIVIDE | _EM_INVALID | _EM_DENORMAL)
#else
    #define D_FLOAT_EXCEPTIONS_MASK (FE_DIVBYZERO | FE_INVALID | FE_INEXACT)
#endif

It is a shame the new c++ standards has not standardized exception handling, liek the did for atomics, thread, mutex, ect.

in any case, the exceptions are only valid in windows system, all othe OS ignored it. This is good for debugging and to get a clean code with hard to find float bugs, but Later I will add an option to the build system that disable them. production code should not required float exceptions.

Thanks for the report

brechtsanders commented 1 year ago

That's exactly why I stay far away from MSVC: to avoid Microsoft's sometimes deviating standards. Your solution works for me, I just tried it and it builds with MinGW-w64. Thanks!