cpp/preprocessor/conditional

The preprocessor supports conditional compilation of parts of source file. This behavior is controlled by, , , , , and directives.

Explanation
The conditional preprocessing block starts with, or  directive, then optionally includes any number of  directives, then optionally includes at most one  directive and is terminated with  directive. Any inner conditional preprocessing blocks are processed separately.

Each of, , , , and directives control the code block until the first , ,  directive not belonging to any inner conditional preprocessing blocks.

, and  directives test the specified condition (see below) and if it evaluates to true, compiles the controlled code block. In that case subsequent and  directives are ignored. Otherwise, if the specified condition evaluates false, the controlled code block is skipped and the subsequent or  directive (if any) is processed. If the subsequent directive is, the code block controlled by the directive is unconditionally compiled. Otherwise, the directive acts as if it was  directive: checks for condition, compiles or skips the controlled code block based on the result, and in the latter case processes subsequent  and  directives. The conditional preprocessing block is terminated by directive.

The may contain:
 * unary operators in form or . The result is  if the  was defined as a macro name, otherwise the result is.
 * expressions, which detects whether a header or source file exists.
 * expressions, which detects whether a given attribute token is supported and its supported version.

After all macro expansion and evaluation of expressions, any identifier which is not a boolean literal is replaced with the number  (this includes identifiers that are lexically keywords, but not alternative tokens like ).

Then the expression is evaluated as an integral constant expression.

If the evaluates to nonzero value, the controlled code block is included and skipped otherwise.

Note: Until the resolution of, ...  is different from  ...  followed by  because if  is true, the second  is skipped and  does not need to be well-formed, while 's  must be a valid expression. As of CWG 1955, that leads the skipped code block is also skipped.

Combined directives
Checks if the identifier was defined as a macro name.

is essentially equivalent to.

is essentially equivalent to.