Re: [OT] calling isnan
Re: [OT] calling isnan
- Subject: Re: [OT] calling isnan
- From: Fred Bacon <email@hidden>
- Date: Fri, 18 Feb 2005 15:20:29 -0500
- Organization: Rigid Rotor
On Fri, 2005-02-18 at 11:40 -0800, Chris Espinosa wrote:
> isnan is a macro, so according to the linker, it is undefined.
Chris,
You are correct. I misspoke with I said the linker was complaining.
Instead, the compiler is complaining about an undefined function isnan.
My current thinking is that the file cmath is the one clobbering the
isnan macro. That file contains the line
#undef isnan
Here is a short example that shows this happening.
#include <math.h>
#include <iostream>
int
main( int argc, char* argv[] )
{
double value;
if ( argc != 2 )
return 1;
value = atof( argv[1] );
if ( isnan (value) )
std::cout << "Value is not a number." << std::endl;
else
std::cout << "Value on command line was: " << value << std::endl;
return 0;
}
Now if you compile this with the line (I named the file main.cpp,
substitute whatever name you choose.)
g++ -o goofy -Wall main.cpp -lm
You get the error message
main.cpp: In function `int main(int, char**)':
main.cpp:15: error: `isnan' undeclared (first use this function)
main.cpp:15: error: (Each undeclared identifier is reported only once
for each function it appears in.)
--
=============================================================================
Fred Bacon email: email@hidden
Aerodyne Research, Inc. http://www.aerodyne.com
45 Manning Rd Phone: (978) 663-9500 ext 273
Billerica, MA 01821-3976 FAX: (978) 663-4918
=============================================================================
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden