On Feb 10, 2008 12:55 PM, Jim Razmus <[EMAIL PROTECTED]> wrote:
> * Chris Kuethe <[EMAIL PROTECTED]> [080210 12:34]:
> > On Feb 10, 2008 8:31 AM, Jim Razmus <[EMAIL PROTECTED]> wrote:
> > > I'm trying to compile a program that uses NAN.  It includes math.h which
> > > I'm told C99 says should define it.  I've grepped the entire source tree
> > > and read up on man 3 math and man 3 isinf.  Still no joy.
> > >
> > > Trying to compile the program yields "error: `NAN' undeclared (first use
> > > in this function)".
> > >
> > > Can anyone point me in the right direction?
> >
> > #ifndef NAN
> > #define NAN (0.0/0.0)
> > #endif
> >
> >
> > --
> > GDB has a 'break' feature; why doesn't it have 'fix' too?
> >
>
> I'm told that math.h should do this for me.  Moreover, I think NAN is a
> machine dependent value.
>
> Adding the line you mention would break on VAX (assuming I understand
> this correctly).  Although I don't think anyone would run this program
> on a VAX, if it's in the ports tree there's the possibility.
>
> Worst case, I could add those defines though.
>
> Thanks.
> Jim

Is your source familiar with OpenBSD?
You say C99 math.h supposedly provides NAN.
math(3) says nothing about C99.  That's your first clue.
Looking through gcc(1) for -std=c99 points to the GCC webpage [1].
It says "additional math library functions" are missing.  That might
be another clue.

If you can't use NAN in a simple test program using -std=c99 and/or
-lm, you're SOL unless you start patching your program.

Both math(3) and the source for isnan(3) (see [2]) indicate that there
are many potential NaN values.  Unless you know exactly what this
program is doing or are very familiar with your arch's floating point
support, don't assume that #define will work 100% of the time.

I'm no expert though.  Good luck.

--david

[1] http://gcc.gnu.org/gcc-3.3/c99status.html
[2] http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/s_isnan.c

Reply via email to