Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Syntax coloring

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
BobF Posted - Apr 25 2008 : 10:17:32 AM
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
}

4   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Apr 25 2008 : 4:33:36 PM
Easy when you know how
BobF Posted - Apr 25 2008 : 1:55:33 PM
Feline,

That suggestion worked.

Thanks.
Bob
feline Posted - Apr 25 2008 : 1:05:16 PM
Try turning off:

IDE tools menu -> Options -> Text Editor -> C/C++ -> Formatting -> Colorize inactive code blocks in a different color
rhummer Posted - Apr 25 2008 : 10:57:12 AM
This coloring is done by the IDE, and I find it to be pretty buggy at least with VS2005, not sure about VS2008

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000