What does this do?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • user

    #1

    What does this do?

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

  • Victor Bazarov

    #2
    Re: What does this do?

    user wrote:[color=blue]
    > What's the meaning of these two lines?
    > extern const double __infinity;
    > #define INFINITY __infinity
    >[/color]

    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

    Comment

    • imanpreet@gmail.com

      #3
      Re: What does this do?

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

      --
      Imanpreet Singh Arora

      Comment

      • CBFalconer

        #4
        Re: What does this do?

        user wrote:[color=blue]
        >
        > What's the meaning of these two lines?
        > extern const double __infinity;
        > #define INFINITY __infinity[/color]

        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 (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
        Available for consulting/temporary embedded and systems.
        <http://cbfalconer.home .att.net> USE worldnet address!

        Comment

        Working...