Condition Variables

Condition variables can be used in expressions in #if, #ifdef, #ifndef, and #elif statements. For example:

#if VER < 3 && DEF_OPEN != 0
    ....

In this example, two condition variables are used: VER and DEF_OPEN. Each variable value can be specified using the Edit Condition command.

Each condition variable can have any textual value. As in C and C++, any numerical value that equals zero is considered “False”, and any non-zero value is “True”.

Ignoring Condition Variables

If you do not specify a variable’s value, then any statement that includes that variable is skipped and simply ignored. This is the default behavior for any #if-type statement.

For example:

#if VER < 3 && WINVER >= 5
    int a = 1;
#else
    int a = 2;
#endif

If both VER and WINVER are defined using Edit Condition, then the expression in the #if statement will be evaluated, and only one of the branches will be active. However, if either of those variables are not defined in Source Insight, then both branches will be active.

Editing the Condition Variables

To edit the value of a conditional variable, right-click on it and select Edit Condition. When you edit the condition list, Source Insight will ask you if you want to re-parse your whole project. You should make all your changes to the condition list first, and then re-parse your whole project. Until your project is re-parsed, the symbol information stored in Source Insight’s symbol database will not reflect the changes you made.