Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
GCC 3.1 <cmath> and isnan etc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GCC 3.1 <cmath> and isnan etc



This has been mentioned before but the <cmath> header really has a error in it's handling of isnan.

If you include <cmath> anywhere in your C++ code, you lose access to isnan, isfinite etc.

In pure "C" code that includes <math.h> isnan() etc. are #define'd in <math.h> as macros.
<cmath> tries to change that to functions that live in the std:: namespace.

By default GLIBCPP_USE_C99 is undefined (and defining it causes all sorts of other compile errors)

#if _GLIBCPP_USE_C99
// do some tricky namespace stuff to make isnan "real" functions, not macros
namespace __gnu_cxx
{
...
...
...
}
#endif

#undef isnan <---- #undef'ing this here means that isnan is now lost forever unless _GLIBCPP_USE_C99 is #define'd
#undef isfinite

#if _GLIBCPP_USE_C99
namespace std
{
using __gnu_cxx::fpclassify;
using __gnu_cxx::isfinite;
using __gnu_cxx::isinf;
using __gnu_cxx::isnan;
}
#endif

When I think it should be like.... i.e. do not #undef isnan until you have successfully created new functions in the __gnu_cxx namespace

#if _GLIBCPP_USE_C99
do some tricky namespace stuff to make isnan "real" functions, not macros
namespace __gnu_cxx
{
}

#undef isnan
#undef isfinite

#endif
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.