Fixed build error reported on gcc 4.6.4/Ubuntu 12.04 32bit, issue #108

This commit is contained in:
Robert Osfield 2016-07-31 11:06:51 +01:00
parent 953b150c17
commit 1794374c78

View File

@ -28,8 +28,6 @@
#include "utf8_string"
using namespace std;
// A simple class wrapping ofstream calls to enable generic cleaning of json data.
// Especially 'standard' json should:
// * have utf-8 encoded string
@ -37,8 +35,11 @@ using namespace std;
// * does not support inf or nan values
#if defined(WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<=1700)
namespace std
{
inline int isfinite( double x ) { return _finite( x ); }
inline int isinf( double x ) { return !_finite( x ) && !_isnan( x ); }
}
#endif
@ -91,11 +92,11 @@ class json_stream : public osgDB::ofstream {
}
double to_valid_float(const double d) {
if(isfinite(d)) {
if(std::isfinite(d)) {
return d;
}
else {
if(isinf(d)) {
if(std::isinf(d)) {
return std::numeric_limits<double>::max();
}
// no much way to do better than replace invalid float NaN by 0