Compiler directives: #if

Syntax

#if constexpr
statements
[#else
statements]
[#endif]

 

Parts

constexpr - constant integer expression. Also can be global variable of type int, user-defined function of type int (function is executed while compiling; it runs in QM main thread), or expression with operators (expression is evaluated from left to right, regardless of operator priority).

statements - any statements.

 

Remarks

If value of constexpr is not 0, are compiled statements after #if and skipped statements after #else. Otherwise, are skipped statements after #if and compiled statements after #else.

 

#if... cannot be in other #if... or #else block. If #endif is omitted, are compiled (or skipped) all following statements until end of text.

 

Unlike if, compiler directives are evaluated at compile time.

 

See also: predefined variables, predefined constants, make exe.

 

Example

#if (_winnt>=6)
...
#else
...
#endif