Compiler directives: #ifdef, #ifndef

Syntax

#if[n]def identifier
statements
[#else
statements]
[#endif]

 

Parameters

identifier - global identifier (named constant, type, function, global variable, etc).

statements - any statements.

 

Remarks

If identifier is defined (or not defined, if #ifndef used), are compiled statements after #ifdef (or #ifndef) and skipped statements after #else. Otherwise, are skipped statements after #ifdef (or #ifndef) and compiled statements after #else.

 

If #endif is omitted, are compiled (or skipped) all following statements until the end.

 

QM 2.4.1. #if/#ifdef/#ifndef can be nested in other #if/#ifdef/#ifndef or #else code block. Also now most directives can be tab-indented.

 

See also: #if.

 

Example

 if function "MyFunction" exists, call it:
#ifdef MyFunction
MyFunction 100
#endif