diff --git a/CMakeLists.txt b/CMakeLists.txt index 328dfdd0..61824342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,11 @@ check_cxx_source_compiles( void f() { isnan(0.0);} " HAVE_ISNAN) +check_cxx_source_compiles( + "#include + void f() { std::isnan(0.0);} " + HAVE_STD_ISNAN) + if(CMAKE_COMPILER_IS_GNUCXX) set(WARNING_FLAGS_CXX "-Wall") set(WARNING_FLAGS_C "-Wall") diff --git a/simgear/math/SGGeod.hxx b/simgear/math/SGGeod.hxx index 2ab2b107..8eddbe92 100644 --- a/simgear/math/SGGeod.hxx +++ b/simgear/math/SGGeod.hxx @@ -20,10 +20,6 @@ #include -#ifndef _MSC_VER -using std::isnan; -#endif - // #define SG_GEOD_NATIVE_DEGREE /// Class representing a geodetic location @@ -356,7 +352,10 @@ inline bool SGGeod::isValid() const { - if (isnan(_lon) || isnan(_lat)) return false; + if (SGMiscd::isNaN(_lon)) + return false; + if (SGMiscd::isNaN(_lat)) + return false; #ifdef SG_GEOD_NATIVE_DEGREE return (_lon >= -180.0) && (_lon <= 180.0) && (_lat >= -90.0) && (_lat <= 90.0); diff --git a/simgear/math/SGMisc.hxx b/simgear/math/SGMisc.hxx index 5e69077e..8eaa124e 100644 --- a/simgear/math/SGMisc.hxx +++ b/simgear/math/SGMisc.hxx @@ -92,7 +92,6 @@ public: static S lerp(const S& val0, const S& val1, const T& t) { return val0*(T(1) - t) + val1*t; } -#ifndef NDEBUG /// Returns true if v is a NaN value /// Use with care: allways code that you do not need to use that! static bool isNaN(const T& v) @@ -109,7 +108,6 @@ public: return !(v == v); #endif } -#endif }; #endif diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index a9d12392..c571af2d 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -10,6 +10,7 @@ #cmakedefine HAVE_RINT #cmakedefine HAVE_TIMEGM #cmakedefine HAVE_ISNAN +#cmakedefine HAVE_STD_ISNAN #cmakedefine HAVE_WINDOWS_H #cmakedefine HAVE_MKDTEMP