473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

preprocessor directives

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__)?

Nov 15 '05 #1
5 1182

<ra*******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro 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
Nov 15 '05 #2
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

Nov 15 '05 #3
ra*******@gmail.com 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

Nov 15 '05 #4
it means, if FALSE then execute somefunc() otherwise the second
somefunc().
ra*******@gmail.com 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__)?


Nov 15 '05 #5
Martin Ambuhl wrote:
ra*******@gmail.com 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
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Trying_Harder | last post by:
Is it possible to redefine a macro with global scope after undefining it in a function? If yes, could someone explain how? /If/ my question above isn't very clear you can refer to the...
4
by: Jim Ford | last post by:
I have a single C file with the following code: int f2() { /* Blah-blah */ } int f1() { /* Blah-blah */
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
6
by: Urs Thuermann | last post by:
Does a tool exist to apply C preprocessor expansion to a C source only partially, i.e. replace only some directives? I want to replace some #if's by their expansions, e.g. all #ifdef SOME_SYMBOL,...
21
by: Bogdan | last post by:
Can anyone recommend a program for indentation of C preprocessor directives. My file looks like this: #ifdef a #define b #else #define c #endif int main() {
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
9
by: Bob | last post by:
Hi, Is it possible to change the references in a project by using preprocessor directives? Thanks, Bob
14
by: lagman | last post by:
All, I'm looking for a tool that is able to take my code base (which is full of preprocessor directives) and spit out source code that is "clean" of any preprocessor directives based on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.