NAN option for gcc?

J

jchludzinski

Alright I give up! I thought that to only option I need for NAN,
nan(), nanf(), etc. is -l (after all you use #include <math.h>). But
NO ...

It works with g++. What -l option is required?

Thanks ahead of time,
John

PS> Yes, I've grepped the (infinite) man for gcc.
 
J

jchludzinski

Correction:

"... I thought that the only option I need for NAN,
nan(), nanf(), etc. is -lm (after all you use #include <math.h>)."
 
J

James Hess

Alright I give up! I thought that to only option I need for NAN,
nan(), nanf(), etc. is -l (after all you use #include <math.h>). But
NO ...

It works with g++. What -l option is required?

I don't think nan() or nanf() is standard

maybe you'd have better luck with something like
atod("NaN")

?


-Mysid
 
J

jchludzinski

Actually nanf("") works; although nanf(NULL) gives a seg. fault. BUT
both compile using gcc -lm, whereas NAN does not. But NAN works with
g++ (no option). What am I getting by using g++ that I'm not getting
with gcc -lm?

---John
 
M

Michael Mair

Alright I give up! I thought that to only option I need for NAN,
nan(), nanf(), etc. is -l (after all you use #include <math.h>). But
NO ...

It works with g++. What -l option is required?

Thanks ahead of time,
John

PS> Yes, I've grepped the (infinite) man for gcc.

Did you use C99 or gnu99 standard (-std=c99/gnu99, of course together
with -lm)?
AFAIR, these are no C89 standard library functions.
This may make a difference w.r.t. what is available from the standard
library (apart from the usual gcc argument that the library is not
their part).
Note that this is not entirely topical in comp.lang.c.
gcc specific questions are usually better asked in gcc.gnu.help.


Cheers
Michael
 
J

jchludzinski

Yep, that worked: gcc -lm -std=c99. Thanks much!

---John

PS> Next time I'll direct gcc questions to gcc.gnu.help.
 
M

Michael Mair

Yep, that worked: gcc -lm -std=c99. Thanks much!

You are welcome. Just as an aside: -lm belongs _after_ the compile
functions, see
<[email protected]>
(This is a message ID, you can use it to find the message, e.g.
with groups.google.com)
---John

PS> Next time I'll direct gcc questions to gcc.gnu.help.

Okay. One thing: Please quote a minimum of the message you are
referring to so that everyone sees the context. Otherwise, people
may see only your reply for some hours or days or forever without
having the least clue what you are responding to. See CB Falconer's
signature if you are using google for your newsgroup participation.


Cheers
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top