NAN option for gcc?

Discussion in 'C Programming' started by jchludzinski@gmail.com, May 18, 2005.

  1. Guest

    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.
    , May 18, 2005
    #1
    1. Advertising

  2. Guest

    Correction:

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

  3. James Hess Guest

    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
    James Hess, May 18, 2005
    #3
  4. Guest

    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
    , May 18, 2005
    #4
  5. Ben Pfaff Guest

    "James Hess" <> writes:

    > 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
    Ben Pfaff, May 18, 2005
    #5
  6. Michael Mair Guest

    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.
    Michael Mair, May 18, 2005
    #6
  7. Guest

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

    ---John

    PS> Next time I'll direct gcc questions to gcc.gnu.help.
    , May 18, 2005
    #7
  8. Michael Mair Guest

    [OT] (was: NAN option for gcc?)

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


    You are welcome. Just as an aside: -lm belongs _after_ the compile
    functions, see
    <>
    (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.
    Michael Mair, May 18, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julien ROUZIERES

    g++ -pg option and -shared option

    Julien ROUZIERES, Dec 21, 2004, in forum: C++
    Replies:
    1
    Views:
    711
    GianGuz
    Dec 21, 2004
  2. Cas
    Replies:
    5
    Views:
    789
    Kevin Jones
    Aug 28, 2006
  3. Joakim Hove

    Compiler (gcc) option to abort on nan?

    Joakim Hove, Sep 6, 2004, in forum: C Programming
    Replies:
    3
    Views:
    2,160
    Brian Gough
    Sep 6, 2004
  4. max(NaN,0) should be NaN

    , Aug 28, 2006, in forum: C Programming
    Replies:
    61
    Views:
    1,251
    Michel Hack
    Sep 8, 2006
  5. Replies:
    6
    Views:
    1,514
    Richard Tobin
    Mar 19, 2009
Loading...

Share This Page