diff --git a/lib/nimbase.h b/lib/nimbase.h index 0e037cd311..ebc919b0b3 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -491,13 +491,22 @@ typedef char* NCSTRING; #define paramCount() cmdCount -// NAN definition copied from math.h included in the Windows SDK version 10.0.14393.0 -#ifndef NAN +#ifndef NAN /* use __builtin_nanf which is faster, if available */ +# if defined(__GNUC__) +# define NAN (__builtin_nanf("")) +# elif defined(__clang__) /* XXX: writing __has_builtin this line cause MSVC complains. */ +# if __has_builtin (__builtin_nanf) +# define NAN (__builtin_nanf("")) +# endif +# endif +#endif + +#ifndef NAN /* modified from math.h included in the Windows SDK version 10.0.26100.0 */ # ifndef _HUGE_ENUF -# define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow +# define _HUGE_ENUF 1e+300 /* _HUGE_ENUF*_HUGE_ENUF must overflow */ # endif # define NAN_INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF)) -# define NAN ((float)(NAN_INFINITY * 0.0F)) +# define NAN (-(float)(NAN_INFINITY * 0.0F)) #endif #ifndef INF