![](https://secure.gravatar.com/avatar/4481e435b181ecbb4e5a43abeeadd5e9.jpg?s=120&d=mm&r=g)
isnan without the std:: qualifier doesn't compile for me on mingw gcc 3.2.3. Are we going to need a platform-specific hack here?
Same for me (cross-compiling). Is there a way to change is so that everyone is happy?
using namespace std ???
Adib.
![](https://secure.gravatar.com/avatar/bb65b6b3a109d97cf9f8d6c014ede042.jpg?s=120&d=mm&r=g)
I remember Fred said that std:: does not work on OSX (but i may be wrong, I didn't pay close attention then). Is there anyone who knows the entire story?
![](https://secure.gravatar.com/avatar/80decf98697d22779f6f740f8855b88c.jpg?s=120&d=mm&r=g)
isnan unfortunately isn't part of the C++ standard.
Availability of isnan, std::isnan, _isnan and friends can vary according to whether <math.h> has been #included (perhaps indirectly such as by C-based libraries that we use) and whether <cmath> has been #included (perhaps indirectly such as by standard C++ headers that we #include).
We may need to write our own isnan.h header.
Does anyone know whether `x != x' is a portable definition of isnan?
(`(libc)FP Comparison Functions' says that `!=' doesn't raise an exception for NaN in IEEE arithmetic, btw.)
pjrm.
![](https://secure.gravatar.com/avatar/214fe9a0ecb4aed8994e8618ade6f5a8.jpg?s=120&d=mm&r=g)
Peter Moulder wrote:
isnan unfortunately isn't part of the C++ standard.
Availability of isnan, std::isnan, _isnan and friends can vary according to whether <math.h> has been #included (perhaps indirectly such as by C-based libraries that we use) and whether <cmath> has been #included (perhaps indirectly such as by standard C++ headers that we #include).
We may need to write our own isnan.h header.
Does anyone know whether `x != x' is a portable definition of isnan?
(`(libc)FP Comparison Functions' says that `!=' doesn't raise an exception for NaN in IEEE arithmetic, btw.)
pjrm.
You might look at the macros that are in math.h or cmath or wherever they are. That might be the proper way.
But..... it is possible that this needs to be another test in configure.in.
Or... if this is a switch in config.h.in, then we can have Unices do it via ./configure, and have it hardcoded for Win32.
There seem to be three ways that work on various versions of gcc:
1: Use math.h and call isnan(). 2: Use math.h and call std::isnan() 3: Use <cmath> and call std::isnan()
Bob
![](https://secure.gravatar.com/avatar/dc940f48c5635785f32941f1fbe6b601.jpg?s=120&d=mm&r=g)
Bob Jamison wrote:
There seem to be three ways that work on various versions of gcc:
1: Use math.h and call isnan(). 2: Use math.h and call std::isnan() 3: Use <cmath> and call std::isnan()
In doing a Google search on isnan, one of the first hits was someone's changelog addressing this issue. Might be worth checking what they did.
![](https://secure.gravatar.com/avatar/214fe9a0ecb4aed8994e8618ade6f5a8.jpg?s=120&d=mm&r=g)
Peter Moulder wrote:
We may need to write our own isnan.h header.
I think you are right. In the mingw implementation, <math.h> is actually #undef-ing isnan() when the "c++ bits" are included for __GLIBCPP__.
Defines in config.h are thus ignored. So much for that idea. I think the reason is that Mingw's #include files are broken, as far as isnan() is concerned. Google had some other people's problems with this.
So, as a temporary fix, 1. I added a trivial isnan.h to /src 2. On files that need isnan(), made that the last #include 3. Named the new definition isNaN() in order to avoid name conflicts.
Seems to compile/link on Linux and Mingw nicely now. Someone might try OSX. I would not be surprised if the latest MinGW has the definitions fixed.
Bob
participants (5)
-
Bob Jamison
-
bulia byak
-
Jon A. Cruz
-
Peter Moulder
-
Taraben, Adib