The #if and #elif directives

The #if and #elif directives compare the value of constant_expression to zero:

Read syntax diagramSkip visual syntax diagram#if and #elif directive syntax
                                     V                |

If the constant expression evaluates to a nonzero value, the lines of code that immediately follow the condition are passed on to the compiler.

If the expression evaluates to zero and the conditional compilation directive contains a preprocessor #elif directive, the source text located between the #elif and the next #elif or preprocessor #else directive is selected by the preprocessor to be passed on to the compiler. The #elif directive cannot appear after the preprocessor #else directive.

All macros are expanded, any defined() expressions are processed and all remaining identifiers are replaced with the token 0.

The constant_expression that is tested must be integer constant expressions with the following properties:

If a macro is not defined, a value of 0 (zero) is assigned to it. In the following example, TEST must be a macro identifier:
#if TEST >= 1
   printf("i = %d\n", i);
   printf("array[i] = %d\n", array[i]);
#elif TEST < 0
   printf("array subscript out of bounds \n");