From: James Turner Date: Sun, 16 Sep 2012 15:25:11 +0000 (+0100) Subject: Add an SG_UNUSED macro to SimGear. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=12f85b3d1f714470317f0354a54fcc35bbd000b6;p=simgear.git Add an SG_UNUSED macro to SimGear. Imitate Q_UNSUED from Qt, and provide a Simgear 'unused var' warning suppression macro. Fix up one place where the previous warning suppression attempt (assigning to self) was still producing a warning under clang. --- diff --git a/simgear/math/SGGeodesy.cxx b/simgear/math/SGGeodesy.cxx index 396dae49..09c7ce5a 100644 --- a/simgear/math/SGGeodesy.cxx +++ b/simgear/math/SGGeodesy.cxx @@ -21,6 +21,7 @@ #include +#include #include #include @@ -344,7 +345,8 @@ static int _geo_inverse_wgs_84( double lat1, double lon1, double lat2, } else if( fabs(cosphi1) < testv ) { // initial point is polar int k = _geo_inverse_wgs_84( lat2,lon2,lat1,lon1, az1,az2,s ); - k = k; // avoid compiler error since return result is unused + SG_UNUSED(k); + b = *az1; *az1 = *az2; *az2 = b; return 0; } else if( fabs(cosphi2) < testv ) { @@ -352,7 +354,8 @@ static int _geo_inverse_wgs_84( double lat1, double lon1, double lat2, double _lon1 = lon1 + 180.0f; int k = _geo_inverse_wgs_84( lat1, lon1, lat1, _lon1, az1, az2, s ); - k = k; // avoid compiler error since return result is unused + SG_UNUSED(k); + *s /= 2.0; *az2 = *az1 + 180.0; if( *az2 > 360.0 ) *az2 -= 360.0; diff --git a/simgear/sg_inlines.h b/simgear/sg_inlines.h index 399c4bc1..04df945e 100644 --- a/simgear/sg_inlines.h +++ b/simgear/sg_inlines.h @@ -100,4 +100,7 @@ inline void SG_NORMALIZE_RANGE( T &val, const T min, const T max ) { while( val < min ) val += step; } +// avoid an 'unused parameter' compiler warning. +#define SG_UNUSED(x) (void)x + #endif // _SG_INLINES_H