Bug 480 - Compiler error using GCC 4.4.3 (Android NDK toolchain) in Core/MathFunctions.h
: Compiler error using GCC 4.4.3 (Android NDK toolchain) in Core/MathFunctions.h
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - general
: 3.1
: All Other UNIX-like
: Normal major
Assigned To: Nobody
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-06-26 13:13 UTC by Michael Hofmann
Modified: 2012-12-20 17:00 UTC (History)
3 users (show)



Attachments

Description Michael Hofmann 2012-06-26 13:13:02 UTC
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).
Comment 1 Gael Guennebaud 2012-07-05 17:18:26 UTC
See this thread in the forum:

http://forum.kde.org/viewtopic.php?f=74&t=102930&p=225608&hilit=isfinite#p225608

What we can do is to protect isfinite with parenthesis.
Comment 2 Gael Guennebaud 2012-07-05 17:23:36 UTC
Fixed:

https://bitbucket.org/eigen/eigen/changeset/1fc8deb4fedb/
changeset:   1fc8deb4fedb
user:        ggael
date:        2012-07-05 17:22:25
summary:     Fix bug 480: workaround the Android NDK defining isfinite as a
macro

https://bitbucket.org/eigen/eigen/changeset/c8e060b47beb/
changeset:   c8e060b47beb
branch:      3.1
user:        ggael
date:        2012-07-05 17:22:25
summary:     Fix bug 480: workaround the Android NDK defining isfinite as a
macro
(transplanted from 1fc8deb4fedba96f7e5a470edc314985cac4c7d3)
Comment 3 Christoph Hertzberg 2012-12-20 17:00:04 UTC
*** Bug 484 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.