From 587adca056af064a9b7e70e498880231b549bd9c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 15 May 2006 11:53:21 +0000 Subject: [PATCH] From Eric Wing, compile fix for OSX. --- include/osg/Math | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/osg/Math b/include/osg/Math index 25235f254..e16e351ab 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -16,13 +16,27 @@ #include - //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__ #include #if !defined(MAC_OS_X_VERSION_10_2) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2) -#define APPLE_PRE_10_2 + // One extra check to verify the gcc version. + // The assumption is that there is no possible way to use gcc 4+ + // on anything less than 10.3.9. So if gcc 4 is in use, this means + // pre-10.2 support is not intended and we need not define APPLE_PRE_10_2. + // The reason for this extra check is that if the user relies on default + // settings, MAC_OS_X_VERSION_MIN_REQUIRED will be set to 1010 and hit + // 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 is used elsewhere + // in the code. seems to undef isnan which causes compile + // failures below. Using std::isnan will work, but use of + // and std:: are not necessarily portible with other systems so + // the include of is isolated here. + #include + #endif #endif #endif @@ -172,10 +186,16 @@ inline double round(double v) { return v>=0.0?floor(v+0.5):ceil(v-0.5); } inline bool isNaN(float v) { return _isnan(v)!=0; } inline bool isNaN(double v) { return _isnan(v)!=0; } #else - # if defined(__APPLE__) && !defined (APPLE_PRE_10_2) - inline bool isNaN(float v) { return __isnanf(v); } - inline bool isNaN(double v) { return __isnand(v); } + #if defined(__APPLE__) + #if !defined (APPLE_PRE_10_2) + inline bool isNaN(float v) { return __isnanf(v); } + inline bool isNaN(double v) { return __isnand(v); } + #else + inline bool isNaN(float v) { return std::isnan(v); } + inline bool isNaN(double v) { return std::isnan(v); } + #endif #else + // Need to use to std::isnan to avoid undef problem from inline bool isNaN(float v) { return isnan(v); } inline bool isNaN(double v) { return isnan(v); } #endif