Link to home
Start Free TrialLog in
Avatar of richelieu7777
richelieu7777

asked on

Visual Studio.NET 'C/C++' Gives Active Text the Inactive Text Color Between Preprocessor Directives

I am still having the same problem in VS 2008 that I had in VS 2005.  It was somewhat intermittent in VS 2005, but seems to be a constant problem in VS 2008.

Let's say that "_RDEF3" is a preprocessor directive.  [I assigned "_RDEF3" in the Configuration Properties->C/C++->Preprocess Definitions section of the project properties]

I have code that states:

#ifdef _RDEF3
      blah
      blah
      blah
#else
      blah2
      blah2
      blah2
#endif

When Visual Studio detects code between #ifdef's that is inactive, it displays it in gray.  This is a really nice feature -- when it works.

The problem is that the "blah" text above, between the "#ifdef _RDEF3" and "#else" is grayed out and the "blah2" text is not.  However, when I debug the code, the "blah" text gets executed because "_RDEF#" is, in fact, a preprocessor directive.

Very strange.  On the one hand, VS thinks the text is inactive when in the text editor, on the other, it executes it because it thinks it IS active.

If I remove the "_" in "_RDEF3" then put it back, the "blah" text *DOES* become active.  But not for long.  If I press F5 to start executing the Debug version of the code, it immediately goes back to gray.


I thought VS 2008 would have fixed this by now.

Avatar of jkr
jkr
Flag of Germany image

One workaround for this - not nice, I know - is to use #define directives instead of the project settings. This also exposes the same glitch sometimes, but *most* of the time it's consistent.
ASKER CERTIFIED SOLUTION
Avatar of richelieu7777
richelieu7777

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial