gcc-3.3.3 :fpclassify

Dave Korn dave.korn@artimi.com
Thu Dec 30 23:01:00 GMT 2004

> -----Original Message-----
> From: cygwin-talk-owner On Behalf Of Jianguo.Zhang
> Sent: 30 December 2004 20:56

> The gcc/g++ version is 3.3.3
> I am trying to compile the following program using g++ 3.3.3

>          if (FP_ZERO != std::fpclassify (a)) abort ();        
>    if (FP_NAN != std::fpclassify (b)) abort ();               
>   if (FP_NORMAL != std::fpclassify (c)) abort ();             

> When I use the following command to compile this file under cygwin:
> $ g++ test.cpp
> the following errors occurs:
> test.cpp: In function `int main()':
> test.cpp:17: error: `fpclassify' undeclared in namespace `std'
> test.cpp:18: error: `fpclassify' undeclared in namespace `std'
> test.cpp:19: error: `fpclassify' undeclared in namespace `std'
> there is no problem to compile the file under linux system 
> using g++ 3.3.1
> Could anyone tell me why?

  It changed in 3.3.3; in earlier versions it was indeed in namespace std.

  It is a macro, defined in /usr/include/math.h, which is included by cmath, but
then (since 3.3.3) cmath has a section that undefines it again; this is
apparently for strict c++ standard conformance.

  In gnu libstdc++, the macro is placed into namespace __gnu_cxx before it is
undefined, used to make a template function that will accept any type, and then
imported from there to std:: later.  This is under the control of two #defines,
_GLIBCPP_USE_C99 and _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC.  Unfortunately, these
can't just be set at the top of your code before the #includes, as then cstdlib
goes and breaks.  These defines live in
/usr/include/c++/3.3.3/i686-pc-cygwin/bits/c++config.h, and they are created at
the time the compiler itself is being configured and built.

  The cygwin compiler, it seems, was compiled without using the --enable-c99
option at configure time, whereas the linux version you've used was.

and follow ups, and particularly the referenced thread
make it clear what's going on.

  There are various answers and workarounds.  One would be to recompile gcc
(perhaps just libstdc++ would be enough) for cygwin with --enable-c99.  Another
would be to copy the definitions into your own code from math.h.

  Gerrit, does the output from "gcc -v" for 3.4.1 show "--enable-c99"?  Or has
someone fixed it in the headers somehow?

Can't think of a witty .sigline today....

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list