preprocessor directives

Discussion in 'C Programming' started by rahul8143@gmail.com, Oct 5, 2005.

  1. Guest

    hello,
    how to interprete following #if in code? e.g. if i have a code
    like
    #if 0
    somefunc();
    else
    somefunc();
    #endif

    also what is meaning of
    #if !defined(__ENVVAR__)?
     
    , Oct 5, 2005
    #1
    1. Advertising

  2. Mike Wahler Guest

    <> wrote in message
    news:...
    > hello,
    > how to interprete following #if in code? e.g. if i have a code
    > like
    > #if 0
    > somefunc();
    > else


    #else

    > somefunc();
    > #endif


    The above (after my correction) means that only
    the second call to 'somefunc()' (after the #else)
    will become part of the translation unit. The
    first call is excluded.

    >
    > also what is meaning of
    > #if !defined(__ENVVAR__)?


    It means that if, at this point, the preprocessor has not
    encountered a definition of '__ENVVAR__', then everything
    after the #if, up to the next #endif, #else, or #elif
    will become part of the translation unit. If a definition
    of '__ENVVAR' was already encountered, the inverse would
    be true (everything between the #if and the next #endif,
    #else, or #elif would be excluded).

    This is all basic stuff. Which C textbook(s) are you
    reading?

    -Mike
     
    Mike Wahler, Oct 5, 2005
    #2
    1. Advertising

  3. Guest

    Hello,
    Happy Harmony is the fastest growing matrimonial portal for
    Indians.
    You can email and IM other members without paying anything on this
    site.
    The amazing thing is that this site is totally free. Absolutely free.
    Cannot believe? Then click on this link to visit and register Happy
    Harmony.
    http://www.happyharmony.com/?idAff=14
    Background check is the new facility they have added now. You can do a
    free
    background check including age, address, phone numbers, property
    owneship
    information etc of anybody in the US.

    Regards,
    Resh
     
    , Oct 5, 2005
    #3
  4. wrote:
    > hello,
    > how to interprete following #if in code? e.g. if i have a code
    > like
    > #if 0


    if 0 is non-zero (never), use the lines that follow up to the #endif,
    #else, or #elif
    (This is the normal way to comment out code, for example.)

    > somefunc();
    > else


    'else' here means "please abort the compilation or at least warn about
    this error".

    > somefunc();
    > #endif
    >
    > also what is meaning of
    > #if !defined(__ENVVAR__)


    ['?' deleted from the above]

    if __ENVVAR__ is not defined, use the lines that follow up to the
    #endif, #else, or #elif
     
    Martin Ambuhl, Oct 5, 2005
    #4
  5. Kuku Guest

    it means, if FALSE then execute somefunc() otherwise the second
    somefunc().
    wrote:
    > hello,
    > how to interprete following #if in code? e.g. if i have a code
    > like
    > #if 0
    > somefunc();
    > else
    > somefunc();
    > #endif
    >
    > also what is meaning of
    > #if !defined(__ENVVAR__)?
     
    Kuku, Oct 5, 2005
    #5
  6. Eric Sosman Guest

    Martin Ambuhl wrote:
    > wrote:
    >
    >> hello,
    >> how to interprete following #if in code? e.g. if i have a code
    >> like
    >> #if 0

    >
    >
    > if 0 is non-zero (never), use the lines that follow up to the #endif,
    > #else, or #elif
    > (This is the normal way to comment out code, for example.)
    >
    >> somefunc();
    >> else

    >
    >
    > 'else' here means "please abort the compilation or at least warn about
    > this error".


    Why? The material between `#if 0' and `#endif' must
    be a valid stream of tokens, but need not be valid C.

    --
    Eric Sosman
     
    Eric Sosman, Oct 5, 2005
    #6
    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. Replies:
    0
    Views:
    2,682
  2. Nalla
    Replies:
    25
    Views:
    896
    MikeyD
    Oct 8, 2003
  3. seemanta dutta

    how to make elegant use of preprocessor directives

    seemanta dutta, Nov 27, 2003, in forum: C Programming
    Replies:
    13
    Views:
    641
    Randy Howard
    Dec 1, 2003
  4. IndyChris
    Replies:
    1
    Views:
    8,872
    bruce barker \(sqlwork.com\)
    Aug 9, 2006
  5. Theon Greyjoy

    Preprocessor directives in codebehind file

    Theon Greyjoy, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,540
    bruce barker \(sqlwork.com\)
    Oct 6, 2006
Loading...

Share This Page