Programming in C

(Barry) #1
9.0 The Preprocessor 463

produces
printf ("x10 = %i\n", x10);
after substitution and concatenation of the character strings.
Spaces are not required around the #and ##operators.

9.2.2 The #errorDirective
The general format for declaring the #errordirective is as follows:
#error text
...
The specified textis written as an error message by the preprocessor.

9.2.3 The #ifDirective
One general format for declaring the #ifdirective is as follows:
#if constant_expression
...
#endif
The value of constant_expressionis evaluated. If the result is nonzero, all program
lines up until the #endifdirective are processed; otherwise, they are automatically
skipped and are not processed by the preprocessor or by the compiler.
Another general format for declaring the #ifdirective is as follows:
#if constant_expression_1
...
#elif constant_expression_2
...
#elif constant_expression_n
...
#else
...
#endif
If constant_expression_1is nonzero, all program lines up until the #elifare
processed, and the remaining lines up to the #endifare skipped. Otherwise, if
constant_expression_2is nonzero, all program lines up until the next #elifare
processed, and the remaining lines up to the #endif are skipped. If none of the constant
expressions evaluates to nonzero, the lines after the #else(if included) are processed.
The special operator definedcan be used as part of the constant expression, so
#if defined (DEBUG)
...
#endif

20 0672326663 AppA 6/10/04 2:01 PM Page 463

Free download pdf