After upgrading our IDE from Visual Studio 2010 (VC10) to Visual Studio 2013 (VC12), our use of dInfinity
, a macro defined in Open Dynamics Engine (ODE), started to generate compiler warnings:
C4056: overflow in floating-point constant arithmetic
C4756: overflow in constant arithmetic
In odeconfig.h (ode)
#ifdef INFINITY
#define dInfinity INFINITY
#elif defined(HUGE_VAL)
#ifdef dSINGLE
#ifdef HUGE_VALF
#define dInfinity HUGE_VALF
#else
#define dInfinity ((float)HUGE_VAL)
#endif
#else
#define dInfinity HUGE_VAL
#endif
#else
#ifdef dSINGLE
#define dInfinity ((float)(1.0/0.0))
#else
#define dInfinity (1.0/0.0)
#endif
#endif
In math.h (VC12; The comments in there are from the header file, I did not add them there.)
#define _HUGE_ENUF 1e+300 /* _HUGE_ENUF*_HUGE_ENUF must overflow */
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF)) /* causes warning
C4756: overflow in constant arithmetic (by design) */
The previous version was probably using HUGE_VAL
which did not spam warnings.
C4756
seems to come from the simple use in a float
and C4056
seems a result to an implicit conversion to a double
.
Can I simply ignore these warnings by wrapping the inclusion of odeconfig.h
in #pragma warning push
/pop
, or is there really something bad going on?
Edit:
After looking at an old setup, the previous implementation used HUGE_VAL
defined in math.h.