Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Syntax coloring
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BobF
New Member

9 Posts

Posted - Apr 25 2008 :  10:17:32 AM  Show Profile  Reply with Quote
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
}

rhummer
Tomato Guru

USA
527 Posts

Posted - Apr 25 2008 :  10:57:12 AM  Show Profile  Reply with Quote
This coloring is done by the IDE, and I find it to be pretty buggy at least with VS2005, not sure about VS2008

Tools Engineer - Raven Software
VS2005 SP2/VS2008 SP1 - VAX <LATEST> - Win 7 x64

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Apr 25 2008 :  1:05:16 PM  Show Profile  Reply with Quote
Try turning off:

IDE tools menu -> Options -> Text Editor -> C/C++ -> Formatting -> Colorize inactive code blocks in a different color

zen is the art of being at one with the two'ness
Go to Top of Page

BobF
New Member

9 Posts

Posted - Apr 25 2008 :  1:55:33 PM  Show Profile  Reply with Quote
Feline,

That suggestion worked.

Thanks.
Bob
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Apr 25 2008 :  4:33:36 PM  Show Profile  Reply with Quote
Easy when you know how

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000