From: James Turner Date: Sun, 22 Dec 2013 11:18:48 +0000 (+0000) Subject: Use a real function to wrap isfinite differences. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0940a339071ad3662c795a42dddd7546928968f7;p=flightgear.git Use a real function to wrap isfinite differences. Don't worry about compiler ability to inline the macro for the moment; use a real function to ensure lookup is stable on different compilers. --- diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 39642d76e..f05a58917 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -33,16 +33,11 @@ #include #include -#include -#include - -#ifdef _MSC_VER -# include -# define isfinite(x) _finite(x) -#else -# define isfinite(x) std::isfinite(x) -#endif +#include +#include +// defined in AIShip.cxx +extern double fgIsFinite(double x); #include "AIAircraft.hxx" #include "performancedata.hxx" @@ -945,7 +940,7 @@ void FGAIAircraft::controlHeading(FGAIWaypoint* curr) { SG_NORMALIZE_RANGE(calc_bearing, 0.0, 360.0); } - if (isfinite(calc_bearing)) { + if (fgIsFinite(calc_bearing)) { double hdg_error = calc_bearing - tgt_heading; if (fabs(hdg_error) > 0.01) { TurnTo( calc_bearing ); diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 5d94dd284..d82c3963d 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -21,15 +21,15 @@ # include #endif +#include + #ifdef _MSC_VER # include -# define isfinite(x) _finite(x) + double fgIsFinite(double x) { return _finite(x); } #else -# define isfinite(x) std::isfinite(x) + double fgIsFinite(double x) { return std::isfinite(x); } #endif -#include - #include #include #include @@ -792,7 +792,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { // now revise the required course for the next way point _course = getCourse(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr->getLatitude(), curr->getLongitude()); - if (isfinite(_course)) + if (fgIsFinite(_course)) TurnTo(_course); else SG_LOG(SG_AI, SG_ALERT, "AIShip: Bearing or Range is not a finite number");