2 Replies Latest reply: Jul 30, 2013 4:04 AM by 1029026 RSS

    Using isfinite on Solaris 11.1 x86 with CC from Solaris Studio 12.3

    1029026

      Hello,

       

      I am trying to build GEOS , a C++ API that uses isfinite. From the man page, isfinite is defined in math.h and is a c99 feature.

       

      The header is properly included the build fails with error :

       

      /bin/sh ../../libtool --tag=CXX   --mode=compile CC -DHAVE_CONFIG_H -I. -I../../include -I../../include/geos -I../../include -m64 -g -library=stlport4 -library=Crun -c -o HCoordinate.lo HCoordinate.cpp

      libtool: compile:  CC -DHAVE_CONFIG_H -I. -I../../include -I../../include/geos -I../../include -m64 -g -library=stlport4 -library=Crun -c HCoordinate.cpp  -KPIC -DPIC -o .libs/HCoordinate.o

      "HCoordinate.cpp", line 76: Error: The function "isfinite" must have a prototype.

      "HCoordinate.cpp", line 76: Error: The function "isfinite" must have a prototype.

      "HCoordinate.cpp", line 153: Error: The function "isfinite" must have a prototype.

      "HCoordinate.cpp", line 164: Error: The function "isfinite" must have a prototype.

      4 Error(s) detected.

      gmake[3]: *** [HCoordinate.lo] Erreur 1

       

       

      In fact, the function is not defined because CC does not define __C99FEATURES__ as c99 does. If I add a -D__C99FEATURES__ parameter to CC, the build ends properly but I think it is not the proper way to do it.

       

      Does anybody knows the right way to do so ?

       

       

      Best regards

      --

      Eric

        • 1. Re: Using isfinite on Solaris 11.1 x86 with CC from Solaris Studio 12.3
          Steve.Clamage-Oracle

          There is currently no support for the C99 math features in Studio C++. We have an outstanding request (bug 16263435) to make the features available, but there are some issues to be resolved. Because of the way the C headers and runtime library are implemented, if you get the C99 math features, you also get C99 (instead of C90) behavior for various types and functions that changed from C90 to C99.

           

          Defining  your own configuration macros, like __C99FEATURES__  is not recommend or supported. Try it at your own risk.

           

          You could consider writing in C the routines that need access to C99 math, and compiling them with the C compiler. Simple example:

           

          file isfinite.c

          -------------------

          #include <math.h>

          #include <stdbool.h>

          bool myisfinite(double x) { return isfinite(x); }

           

           

          file mymath.h

          ---------------------

          extern "C" bool myisfinite(double);

          inline bool isfinite(double x) { return myisfinite(x); }

           

          file myprog.cc

          -------------------

          include "mymath.h"

          void foo()

          {

               ....

              if( isfinite(xval) ) { ... }

              else { ... }

               ...

          }


          % cc -xc99=all isfinite.c

          % CC myprog.cc isfinite.o

          • 2. Re: Using isfinite on Solaris 11.1 x86 with CC from Solaris Studio 12.3
            1029026

            Thanks for your help, I will prevent the configure script to have GEOS use the finite function instead.