Handle isnan at a more central place.

Do not distribute architecture specific
code across a lot of places.
This commit is contained in:
Mathias Froehlich 2012-09-27 18:39:18 +02:00
parent fcd1733787
commit 7bcf02a0b4
4 changed files with 10 additions and 7 deletions

View File

@ -232,6 +232,11 @@ check_cxx_source_compiles(
void f() { isnan(0.0);} " void f() { isnan(0.0);} "
HAVE_ISNAN) HAVE_ISNAN)
check_cxx_source_compiles(
"#include <cmath>
void f() { std::isnan(0.0);} "
HAVE_STD_ISNAN)
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
set(WARNING_FLAGS_CXX "-Wall") set(WARNING_FLAGS_CXX "-Wall")
set(WARNING_FLAGS_C "-Wall") set(WARNING_FLAGS_C "-Wall")

View File

@ -20,10 +20,6 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#ifndef _MSC_VER
using std::isnan;
#endif
// #define SG_GEOD_NATIVE_DEGREE // #define SG_GEOD_NATIVE_DEGREE
/// Class representing a geodetic location /// Class representing a geodetic location
@ -356,7 +352,10 @@ inline
bool bool
SGGeod::isValid() const 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 #ifdef SG_GEOD_NATIVE_DEGREE
return (_lon >= -180.0) && (_lon <= 180.0) && return (_lon >= -180.0) && (_lon <= 180.0) &&
(_lat >= -90.0) && (_lat <= 90.0); (_lat >= -90.0) && (_lat <= 90.0);

View File

@ -92,7 +92,6 @@ public:
static S lerp(const S& val0, const S& val1, const T& t) static S lerp(const S& val0, const S& val1, const T& t)
{ return val0*(T(1) - t) + val1*t; } { return val0*(T(1) - t) + val1*t; }
#ifndef NDEBUG
/// Returns true if v is a NaN value /// Returns true if v is a NaN value
/// Use with care: allways code that you do not need to use that! /// Use with care: allways code that you do not need to use that!
static bool isNaN(const T& v) static bool isNaN(const T& v)
@ -109,7 +108,6 @@ public:
return !(v == v); return !(v == v);
#endif #endif
} }
#endif
}; };
#endif #endif

View File

@ -10,6 +10,7 @@
#cmakedefine HAVE_RINT #cmakedefine HAVE_RINT
#cmakedefine HAVE_TIMEGM #cmakedefine HAVE_TIMEGM
#cmakedefine HAVE_ISNAN #cmakedefine HAVE_ISNAN
#cmakedefine HAVE_STD_ISNAN
#cmakedefine HAVE_WINDOWS_H #cmakedefine HAVE_WINDOWS_H
#cmakedefine HAVE_MKDTEMP #cmakedefine HAVE_MKDTEMP