C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)
#error preprocessor-tokens
preprocessor-tokens
specifies the tokens to be included in the message text.
Example
This example causes the string following #error to be printed as the error message:
#error This message will be issued by the compiler
#if, #elif, #ifdef, #ifndef, #else, and #endif
The four if directives, together with the #else and #endif directives, define the bounds of an
if section, which conditionally includes or excludes source text. An if section consists of:
• An if group, which is one of the four if directives followed by the source text that the compiler
is to include if the controlling condition is true
• An optional else group, which is the #else directive followed by the source text that the
compiler is to include if the controlling condition is false
• The #endif directive, which marks the end of the if section
The four if directives offer different controlling conditions:
Tests the value of a constant expression. If the value is nonzero, the source text in the if group
is included; otherwise, the source text in an elif or else group, if present, is included.
#if
Tests the value of a constant expression. If the value is nonzero, the source text in the elif
group is included; otherwise, the source text in the next elif or else group, if present, is
included.
#elif
Tests the existence of an identifier as a macro name. If the identifier has been defined (using
#define), the source text in the if group is included; otherwise, the source text in the else
group (if present) is included.
#ifdef
Tests the nonexistence of an identifier as a macro name. If the identifier has not been defined,
the source text in the if group is included; otherwise, the source text in the else group (if
present) is included.
#ifndef
if-section:
if-group
[ else-group ]
#endif newline
if-group:
{ #if int-constant-expression } newline [ source-text ]
{ #elif int-constant-expression }
{ #ifdef identifier }
{ #ifndef identifier }
#else-group:
#else newline [ source-text ]
#if 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 #if directive line,
and source-text is the text included if int-constant-expression has a nonzero value.
#if, #elif, #ifdef, #ifndef, #else, and #endif 155