This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cmath isnan function


Ok,

So the following works:

using namespace std;
 #include <math.h>
int main()
{
  float x=sqrt(-1);
  return isnan(x);
}

but when I include cmath, it doesn't.  It seems that cmath is
overidding the math.h isnan macro and not redifining it.  Has anyone
else had this problem?  Is there a way to fix this?

thanks,
wes

On 5/22/05, Wesley Smith <wesley.hoke@gmail.com> wrote:
> I tried:
> 
> using namespace std;
> 
> before everything and it still failed to find isnan.
> 
> wes
> 
> On 5/22/05, Brian Budge <brian.budge@gmail.com> wrote:
> > You need to be using the namespace std.
> >
> > On 5/21/05, Wesley Smith <wesley.hoke@gmail.com> wrote:
> > > Hi,
> > >
> > > I'm trying to compile a test program to see about the isnan function
> > > on my system (apple darwin w/ gcc version 3.3 20030304 (Apple
> > > Computer, Inc. build 1671).  Here's the code:
> > >
> > > #include <cmath>
> > > int main()
> > > {
> > >  float x=sqrt(-1);
> > >  return isnan(x);
> > > }
> > >
> > > Here's the output:
> > >
> > > gcc -o main main.cpp
> > > main.cpp: In function `int main()':
> > > main.cpp:5: error: `isnan' undeclared (first use this function)
> > > main.cpp:5: error: (Each undeclared identifier is reported only once for each
> > >   function it appears in.)
> > >
> > > This is baffling since cmath is included and it redifines the macros
> > > which it includes from math.h.  I completely stumped here and would
> > > appreciate any help.
> > >
> > > thanks,
> > > wes
> > >
> >
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]