Conditional Compilation

Conditionally includes source code according to compile-time symbols.

#if Expression
    ...
#elif Expression
    ...
#else
    ...
#endif

#define Symbol

Predefined Symbols

Symbols and expressions are case-insensitive. #define adds a symbol for the remainder of preprocessing.

Expressions

Use && (and), || (or), ! (not), parentheses, symbol names, 1 (true) or 0 (false). Every conditional block must end with #endif.

Examples

#if WINDOWS
    MsgBox "Windows"
#elif LINUX
    MsgBox "Linux"
#elif OSX
    MsgBox "macOS"
#endif

#if !(WINDOWS || LINUX)
    MsgBox "Not Windows or Linux"
#endif

#define FEATURE_X
#if FEATURE_X
    MsgBox "Feature X enabled"
#endif