#define

Discussion in 'C Programming' started by Ivan, Jan 31, 2008.

  1. Ivan

    Ivan Guest

    Hi all,

    What is the scope of preprocessor #define?
    Does it depends on the compiler?

    Thanks
    Ivan
     
    Ivan, Jan 31, 2008
    #1
    1. Advertising

  2. Ivan

    Richard Bos Guest

    "Ivan" <> wrote:

    > What is the scope of preprocessor #define?


    From that point on to the end of the file, or to a corresponding #undef
    if there is one.

    > Does it depends on the compiler?


    No.

    Richard
     
    Richard Bos, Jan 31, 2008
    #2
    1. Advertising

  3. Ivan

    Guest

    On Jan 31, 4:21 pm, "Ivan" <> wrote:
    > Hi all,
    >
    > What is the scope of preprocessor #define?
    > Does it depends on the compiler?


    anything below the #define line until the end of file, it does not
    depend from the compiler.
     
    , Jan 31, 2008
    #3
  4. "Ivan" <> wrote in message
    >
    > What is the scope of preprocessor #define?
    > Does it depends on the compiler?
    >

    File scope, in all conforming implementations. However #defines are
    frequently placed in headers which are #included by more than one dot c
    file.

    Some compilers separate out the preprocessing step from compilation proper.
    Preprocessing manages the instructions that start with a hash. However this
    will be transparent to you unless you invoke the preprocessor only
    (typically the command is cpp or similar).

    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
     
    Malcolm McLean, Jan 31, 2008
    #4
  5. Ivan

    Guest

    On Jan 31, 8:24 am, (Richard Bos) wrote:
    > "Ivan" <> wrote:
    > > What is the scope of preprocessor #define?

    >
    > From that point on to the end of the file, or to a corresponding #undef
    > if there is one.



    More precisely to the end of the translation unit (or #undef). "End
    of the file" is somewhat ambiguous during preprocessing without
    additional qualification.
     
    , Jan 31, 2008
    #5
    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. Max

    where to define a type?

    Max, Sep 12, 2003, in forum: VHDL
    Replies:
    1
    Views:
    470
    Mike Treseler
    Sep 12, 2003
  2. Elektro
    Replies:
    1
    Views:
    564
    Egbert Molenkamp
    Feb 7, 2005
  3. theotyflos
    Replies:
    3
    Views:
    474
    Thomas Matthews
    Feb 19, 2004
  4. robin liu
    Replies:
    3
    Views:
    824
    Robin Liu
    Apr 21, 2006
  5. Brian Takita

    #define _ and #define __

    Brian Takita, Jan 23, 2006, in forum: Ruby
    Replies:
    0
    Views:
    468
    Brian Takita
    Jan 23, 2006
Loading...

Share This Page