Compiler error using GCC 4.4.3 (Android NDK toolchain) in Core/MathFunctions.h
Submitted by Michael Hofmann
Assigned to Nobody
Link to original bugzilla bug (#480)
Version: 3.1
Operating system: Other UNIX-like
Description
When compiling a translation unit that includes Eigen/Core using GCC 4.4.3 (in this case the standard compiler in the Android NDK toolchain, r8), the following compile error occurs:
In file included from ../Eigen/Core:267,
from .......:
../Eigen/src/Core/MathFunctions.h:848: error: expected unqualified-id before 'sizeof'
../Eigen/src/Core/MathFunctions.h:848: error: expected ')' before 'sizeof'
../Eigen/src/Core/MathFunctions.h:848: error: expected ')' before 'sizeof'
Line 848 is the definition of template<typename T> bool isfinite(const T& x).
This fails to compile since isfinite() is defined as a macro in the toolchain's math.h as follows:
#define isfinite(x) \
((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
: (sizeof (x) == sizeof (double)) ? __isfinite(x) \
: __isfinitel(x))
Two possible solutions could be to either #undef isfinite just before the function template definition or, preferably, to choose another name for the function template (e.g. is_finite).