What does this do?

Discussion in 'C Programming' started by user, Jan 11, 2005.

  1. user

    user Guest

    What's the meaning of these two lines?
    extern const double __infinity;
    #define INFINITY __infinity
    user, Jan 11, 2005
    #1
    1. Advertising

  2. user wrote:
    > What's the meaning of these two lines?
    > extern const double __infinity;
    > #define INFINITY __infinity
    >


    AFAICT, the first one declares a const object of type 'double',
    defined somewhere else in the program, and the second one kind of
    give that object an additional name, "INFINITY". Actually, it
    creates a macro named "INFINITY" that will if used in the code be
    replaced with "__infinity".

    The two lines are actually sort of unrelated. The first one is
    used by the compiler, the second one by the preprocessor.

    V
    Victor Bazarov, Jan 11, 2005
    #2
    1. Advertising

  3. user

    Guest

    __infinity is defined externally to your file, while INFINITY serves as
    a shorthand for __infinity.

    --
    Imanpreet Singh Arora
    , Jan 11, 2005
    #3
  4. user

    CBFalconer Guest

    user wrote:
    >
    > What's the meaning of these two lines?
    > extern const double __infinity;
    > #define INFINITY __infinity


    It is connecting the identifier INFINITY (which is in your address
    space) to the identifier __infinity (which is in the implementors
    address space). What it actually does is going to be described in
    your systems documentation. It is making it possible to revise
    your program to fit some other system with relatively small
    changes, whose purpose etc. should have been thoroughly documented
    near those actual lines.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
    CBFalconer, Jan 12, 2005
    #4
    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. Bill Johnson
    Replies:
    0
    Views:
    1,223
    Bill Johnson
    Jul 8, 2005
  2. Replies:
    3
    Views:
    463
    Ken Cox [Microsoft MVP]
    Oct 7, 2005
  3. Janet Collins
    Replies:
    0
    Views:
    1,127
    Janet Collins
    Jan 13, 2006
  4. Replies:
    1
    Views:
    826
    Juan T. Llibre
    Feb 8, 2006
  5. Alek Nazarian
    Replies:
    7
    Views:
    3,204
    Alek Nazarian
    Oct 22, 2003
Loading...

Share This Page