Conditional Compilation

Top 

 

Preprocessor command lines are used for conditional compilation of various parts of the source text depending on external conditions.

Syntax:

#ifdef identifier

Example:

#ifdef Debug

True, if the Debug identifier was defined earlier by the #define directive. Identifiers can also be defined in the Defines text box in the Script Files dialog.

Syntax:

#ifndef identifier

Example:

#ifndef Debug

 

Syntax:

#else

#endif

If all previous checks of #if, #ifdef, or #ifndef show the True value, then the lines from #else to #endif will be ignored during compilation.

If those checks show the False value, then the lines from the check to #else (and if #else is missing, then from the check to #endif) will be ignored.

The #endif command ends the conditional compilation.

Example:

#ifdef DEBUG   printf("Location: x = %d", x); #endif