C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

The constant expression must evaluate to an integral value; also, it cannot include sizeof or
cast operators or an enumeration constant.
#elif int-constant-expression newline [ source-text ]
introduces an if section that conditionally includes source text based on the value of a constant
expression. The new line following the constant expression terminates the #elif directive line,
and source-text is the text included if int-constant-expression has a nonzero value.
The constant expression must evaluate to an integral value; also, it cannot include sizeof or
cast operators or an enumeration constant.
The maximum number of nested #elif directives is 32.
#ifdef identifier newline [ source-text ]
introduces an if section that conditionally includes source text based on the existence of an
identifier as a macro name. identifier specifies the identifier to test, and the new line
following it terminates the #ifdef directive line. source-text is the source text that is
included if identifier is currently defined as a macro name.
#ifndef identifier newline [ source-text ]
introduces an if section that conditionally includes source text based on the nonexistence of an
identifier as a macro name. identifier specifies the identifier to test, and the new line
following it terminates the #ifndef directive line. source-text is the source text that is
included if identifier is not currently defined as a macro name.
#else newline [ source-text ]
is the else group of an if section. The new line following the #else directive terminates the
directive line. source-text specifies the source text that is included if the condition specified
in the if group is not met.
#endif newline
terminates the if section. The new line following the #endif directive terminates the directive
line.
Usage Guidelines
When using the if directives, remember to distinguish between macro definitions and function
definitions; the #ifdef and #ifndef directives test only macro definitions.
The preprocessor selects a single source-text evaluating the constant expression following
each #if or #elif directive until it finds a true, nonzero, constant-expression. It selects
all text up to its associated #elif, #else, or #endif.
If all occurrences of constant-expression are false, or if no #elif directives appear,
the preprocessor selects the source text after the #else clause. If the #else clause is omitted
and all instances of constant-expression in the #if blocks are false, no source text is
selected.
Examples
1. This example shows how the #if, #else, and #endif directives interact. Because the
identifier ANSI is defined as zero (false), the #if test fails. As a result, the compiler processes
only the source text in the else group:
#define ANSI 0
#if ANSI
printf("Function prototypes supported.\n");
#else
156 Preprocessor Directives and Macros