When code is eliminated with preprocessor commands such as:
#if 0
if(a>b) state=1;
#endif
Then the code in the #if will not be parsed and therefore it will not be colored. That is perfectly fine in this simple example.
The system that I work on has a lot of different confgurations defined in a header file like this:
#if (HWCFG=HW_MODEL_1)
#define SW_MODE SW_MODE_1
#define HW_COMPONENT1_PRESENT
#else if(HWCFG=HW_MODEL_2)
#define SW_MODE SW_MODE_1
#define HW_COMPONENT2_PRESENT
#endif
Then in project settings I will define a HWCFG to use, such as -DHWCFG=HW_MODEL_1
In my code files (coding in C) I will have blocks of code like this:
#if defined(SW_MODE==SW_MODE_1)
executeMode1Function();
#endif
The code inside the #if will not be syntax colored.
If I use #if #else #endif, the first branch seems to always be colored, regardless of what is actually defined in the project setting.
Here is a code snipet that shows what I am describing. Note that the intellisense seem to work correctly
#define HWCFG HW_MODEL_2
#if (HWCFG==HW_MODEL_1)// This should be gray
#define SW_MODE SW_MODE_1
#define HW_COMPONENT1_PRESENT
#else if(HWCFG==HW_MODEL_2) // This should be colored
#define SW_MODE SW_MODE_2
#define HW_COMPONENT2_PRESENT
#endif
void function1()
{
#if 0
if(a>b) state=1;
#endif
}
void function2()
{
#if (SW_MODE==SW_MODE_1)
function1(); // This should be gray
state = 2; // state is gray because it is not declared.
#else
function1(); // This should be colored
#endif
}