#186 Build on Linux 2.6.11 gcc 3.3.5 fail

1.12.0
open
nobody
5
2008-02-28
2008-02-28
Alex
No

version 1.12.1 (is missing in bugtracker)

the compilation on the Debian Linux system fail with following error:

...
In file included from TestAssert.cpp:2:
../../include/cppunit/portability/FloatingPoint.h: In function `int
CppUnit::floatingPointIsFinite(double)':
../../include/cppunit/portability/FloatingPoint.h:41: error: `isfinite'
undeclared (first use this function)
../../include/cppunit/portability/FloatingPoint.h:41: error: (Each undeclared

It seems that the detection of the isfinite function is not working correctly in the configure script, but I can not correct that (no autoconf package installed on system)

from config.log
ac_cv_func_finite=yes
ax_cv_cxx_have_isfinite=yes

configure:21587: checking for isfinite
configure:21620: g++ -o conftest -g -O2 conftest.cpp -lm >&5
configure:21626: $? = 0
configure:21649: result: yes
configure:21666: checking for finite
configure:21722: g++ -o conftest -g -O2 conftest.cpp -lm >&5
configure:21728: $? = 0
configure:21746: result: yes

See mailing list :
http://www.nabble.com/Problem-with-configure-isfinite-finite-detection-td9154892.html

but there is no solution yet available....

Discussion

  • James Piechota
    James Piechota
    2008-04-11

    Logged In: YES
    user_id=2053277
    Originator: NO

    I've hit this issue on SuSE Linux 9.3. In my case the problem is due to cmath replacing the isfinite function (see here for a discussion: http://lists.apple.com/archives/Darwin-development/2002/Aug/msg00485.html\).

    Updating the include/cppunit/portability/FloatingPoint.h file to call std::isfinite when CPPUNIT_HAVE_CMATH is defined worked for me. Here's the diff:

    --- FloatingPoint.h.orig 2008-04-11 09:56:04.000000000 -0700
    +++ FloatingPoint.h 2008-04-11 09:52:27.000000000 -0700
    @@ -2,7 +2,10 @@
    #define CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED

    #include <cppunit/Portability.h>
    +
    +#if not defined(CPPUNIT_HAVE_CMATH)
    #include <math.h>
    +#endif

    CPPUNIT_NS_BEGIN

    @@ -37,7 +40,9 @@
    /// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise.
    inline int floatingPointIsFinite( double x )
    {
    -#if defined(CPPUNIT_HAVE_ISFINITE)
    +#if defined(CPPUNIT_HAVE_CMATH)
    + return std::isfinite( x );
    +#elif defined(CPPUNIT_HAVE_ISFINITE)
    return isfinite( x );
    #elif defined(CPPUNIT_HAVE_FINITE)
    return finite( x );

     
  • Y.L.
    Y.L.
    2008-10-24

    I faced with almost the same error on OpenSolaris x86
    ...
    cppunit-1.12.1/include/cppunit/portability/FloatingPoint.h:43: error: 'finite' was not declared in this scope
    ...

    I resolve this problem by adding following line to "cppunit-1.12.1/include/cppunit/portability/FloatingPoint.h"
    #include <ieeefp.h>

    Maybe something like following should be added to the file FloatingPoint.h
    #if defined(__SVR4)
    #include <ieeefp.h>
    #endif