Description
You can use the #if statement to conditionally include or exclude selected lines of code from the compiled version of your program. This is useful if you need to maintain two or more slightly different versions of your program; #if allows you to maintain them both within the same source file.
If the condition following #if is evaluated as "true" or non-zero, then the statements in statementBlock1 are included in the compilation and the statements (if any) in statementBlock2 are ignored by the compiler. If the condition is evaluated as "false" or zero, then the statements in statementBlock1 are ignored by the compiler, and the statements (if any) in statementBlock2 are included in the compilation.
The #if statement must be matched by a following #endif statement.
condition must have one of the following forms:
constExpr
{def|ndef}_symbolicConstant
constExpr is a "static integer expression." A static integer expression is a valid expression which consists only of:
integer literal constants
previously-defined symbolic constant names
operators (like +, -, *, /, >, ==, !=)
parentheses
In particular, it can't contain variables or function references. If you use this form of #if, then the condition will be evaluated as "true" if the expression's value is nonzero. _symbolicConstant stands for a symbolic constant name. def_symbolicConstant is evaluated as "true" if the indicated constant was previously defined, regardless of its value. ndef_symbolicConstant is evaluated as "true" if the indicated constant was not previously defined.
Because #if can cause lines (including non-executable lines) to be completely ignored by the compiler, you can use it to control such things as the declaration of variables, program labels, constants, and even entire functions.