Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > NAN option for gcc?

Reply
Thread Tools

NAN option for gcc?

 
 
jchludzinski@gmail.com
Guest
Posts: n/a
 
      05-18-2005
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.

 
Reply With Quote
 
 
 
 
jchludzinski@gmail.com
Guest
Posts: n/a
 
      05-18-2005
Correction:

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

 
Reply With Quote
 
 
 
 
James Hess
Guest
Posts: n/a
 
      05-18-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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

 
Reply With Quote
 
jchludzinski@gmail.com
Guest
Posts: n/a
 
      05-18-2005
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

 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      05-18-2005
"James Hess" <(E-Mail Removed)> writes:

> (E-Mail Removed) wrote:
>> 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


They're both in C99.
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
Reply With Quote
 
Michael Mair
Guest
Posts: n/a
 
      05-18-2005
(E-Mail Removed) wrote:
> 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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
 
Reply With Quote
 
jchludzinski@gmail.com
Guest
Posts: n/a
 
      05-18-2005
Yep, that worked: gcc -lm -std=c99. Thanks much!

---John

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

 
Reply With Quote
 
Michael Mair
Guest
Posts: n/a
 
      05-18-2005
(E-Mail Removed) wrote:
> Yep, that worked: gcc -lm -std=c99. Thanks much!


You are welcome. Just as an aside: -lm belongs _after_ the compile
functions, see
<(E-Mail Removed)>
(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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting int to float gives nan (int value is definitely non-nan) googlegroups11@mailinator.com C Programming 6 03-19-2009 03:59 PM
max(NaN,0) should be NaN norb1@yahoo.com C Programming 61 09-08-2006 05:41 PM
no 'option' in aspx file means 'option'="false"? Cas ASP .Net 5 08-28-2006 10:36 AM
g++ -pg option and -shared option Julien ROUZIERES C++ 1 12-21-2004 02:30 PM
Compiler (gcc) option to abort on nan? Joakim Hove C Programming 3 09-06-2004 04:33 PM



Advertisments