Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > preprocessor directives

Reply
Thread Tools

preprocessor directives

 
 
rahul8143@gmail.com
Guest
Posts: n/a
 
      10-05-2005
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__)?

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      10-05-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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


 
Reply With Quote
 
 
 
 
sweet_thiruvonam@yahoo.co.in
Guest
Posts: n/a
 
      10-05-2005
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

 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      10-05-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
Kuku
Guest
Posts: n/a
 
      10-05-2005
it means, if FALSE then execute somefunc() otherwise the second
somefunc().
(E-Mail Removed) 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__)?


 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      10-05-2005
Martin Ambuhl wrote:
> (E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preprocessor directives in codebehind file Theon Greyjoy ASP .Net 1 10-06-2006 08:17 PM
Preprocessor directives must appear as the first non-whitespace character on a line IndyChris ASP .Net 1 08-09-2006 01:21 AM
Preprocessor directives must appear as the first non-whitespace character on a line erin.sebastian@cowaninsurancegroup.com ASP .Net 0 02-14-2006 03:11 PM
how to make elegant use of preprocessor directives seemanta dutta C Programming 13 12-01-2003 02:39 PM
Help needed to count lines between preprocessor directives Nalla C Programming 25 10-08-2003 04:52 PM



Advertisments