Saturday, October 17, 2009

The #ifndef Directive

The #ifndef directive enables you to define code that is to be executed when a particular macro name is not defined.
The general format to use #ifndef is the same as for #ifdef:
becomes this:
result = 12 + 8 * 10;
which assigns 92 to result.
However, if you enclose the macro body in parentheses like this:
#define SUM (12 + 8)
result = (12 + 8) * 10;
and produces the result 200, which is likely what you want.
#ifndef macro_name
statement1
statement2
. . .
statementN
#endif
Here macro_name, statement1, statement2, and statementN have the same meanings as those in the form of #ifdef
introduced in the previous section. Again, the #endif directive is needed to mark the end of the #ifndef block.

No comments:

Post a Comment