From David Guthrie, "I know there are 50,000 changes to osg/Math for OSX a day, but I
think it can be simplified quite a bit. The old code includes <cmath> for pre-10.2 and anything using something other than g++ 4 and then uses std::isnan. For the most current version, it leaves out cmath and uses isnan(). std::isnan and cmath work for the current version, so I just made it include cmath if __APPLE__ is defined and removed the ifdef between versions of OS X for isnan related things. This way the code is all the same, and it's not fragile to someone including <cmath> prior to including osg/Math."
This commit is contained in:
parent
49e7607fa0
commit
62edacece5
@ -19,6 +19,10 @@
|
||||
//certain math functions were not defined until 10.2
|
||||
//so this code checks the version so it can add in workarounds for older versions.
|
||||
#ifdef __APPLE__
|
||||
// Using std::isnan will work for OS X, but use of <cmath>
|
||||
// and std:: are not necessarily portible with other systems so
|
||||
// the include of <cmath> is isolated here.
|
||||
#include <cmath>
|
||||
#include <AvailabilityMacros.h>
|
||||
#if !defined(MAC_OS_X_VERSION_10_2) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2)
|
||||
// One extra check to verify the gcc version.
|
||||
@ -30,12 +34,6 @@
|
||||
// this code path, but this is probably not what they want if using gcc 4+.
|
||||
#if (__GNUC__ < 4)
|
||||
#define APPLE_PRE_10_2
|
||||
// Use of isnan was causing problems if <cmath> is used elsewhere
|
||||
// in the code. <cmath> seems to undef isnan which causes compile
|
||||
// failures below. Using std::isnan will work, but use of <cmath>
|
||||
// and std:: are not necessarily portible with other systems so
|
||||
// the include of <cmath> is isolated here.
|
||||
#include <cmath>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -195,18 +193,8 @@ inline double round(double v) { return v>=0.0?floor(v+0.5):ceil(v-0.5); }
|
||||
inline bool isNaN(double v) { return _isnan(v)!=0; }
|
||||
#else
|
||||
#if defined(__APPLE__)
|
||||
#if !defined (APPLE_PRE_10_2)
|
||||
#if __GNUC__ >= 4
|
||||
inline bool isNaN(float v) { return isnan(v); }
|
||||
inline bool isNaN(double v) { return isnan(v); }
|
||||
#else
|
||||
inline bool isNaN(float v) { return std::isnan(v); }
|
||||
inline bool isNaN(double v) { return std::isnan(v); }
|
||||
#endif
|
||||
#else
|
||||
inline bool isNaN(float v) { return std::isnan(v); }
|
||||
inline bool isNaN(double v) { return std::isnan(v); }
|
||||
#endif
|
||||
inline bool isNaN(float v) { return std::isnan(v); }
|
||||
inline bool isNaN(double v) { return std::isnan(v); }
|
||||
#else
|
||||
// Need to use to std::isnan to avoid undef problem from <cmath>
|
||||
inline bool isNaN(float v) { return isnan(v); }
|
||||
|
Loading…
Reference in New Issue
Block a user