From: Simon on
Hi,

in my StdAfx.h file I have a simple #define to include certain files,
(depending on certain functions I want to add to the application).

One of the new feature of VS2009, (and earlier I think), is to grey out
undefined text

#ifdef SOMETHING
#include "somefile1.h"
#else
#include "somefile2.h"
#endif

In this example one of the two include lines will be greyed out depending on
the definition of SOMETHING.

What I have done is

// ---
// StdAfx.h
....
#define MYMACRO
...

// ---
// MyFile.h
#ifdef MYMACRO
....
#endif

// ---
// MyFile.cpp
#inlcude "stdafx.h"
#inlcude "myfile.h"

#ifdef MYMACRO
....
#endif

And everything works as expected, (the code compiles and works fine)
But regardless whether my macro is defined or not the text is Grey, (and it
is a right pain to work with).

What could be the problem?
If it is a known bug, how can I disable this 'feature'?

Thanks

Simon

From: David Lowndes on
>One of the new feature of VS2009, (and earlier I think), is to grey out
>undefined text
>
>#ifdef SOMETHING
>#include "somefile1.h"
>#else
>#include "somefile2.h"
>#endif
>
>In this example one of the two include lines will be greyed out depending on
>the definition of SOMETHING.
>
>What I have done is
>...
>And everything works as expected, (the code compiles and works fine)
>But regardless whether my macro is defined or not the text is Grey, (and it
>is a right pain to work with).
>
>What could be the problem?

Simon,

It's possible the parser got confused at some point while you were
editing.

I can't reproduce this - it appears to work as expected for me.

Have you tried it in a clean project?

Dave
From: Simon on
> >One of the new feature of VS2009, (and earlier I think), is to grey out
>>undefined text
>>
>>#ifdef SOMETHING
>>#include "somefile1.h"
>>#else
>>#include "somefile2.h"
>>#endif
>>
>>In this example one of the two include lines will be greyed out depending
>>on
>>the definition of SOMETHING.
>>
>>What I have done is
>>...
>>And everything works as expected, (the code compiles and works fine)
>>But regardless whether my macro is defined or not the text is Grey, (and
>>it
>>is a right pain to work with).
>>
>>What could be the problem?
>
> Simon,
>
> It's possible the parser got confused at some point while you were
> editing.

Thanks for the help, I didn't think of that, (don't know why I didn't).
So I deleted my .ncb and .suo file as a test, (that was the cause of many
problem in VC6).

When I first open the project it looks ok, I can even compile it.
But if I make a small change, (delete one character and replace it), then
the text greys out.

If I right click on the macro and choose 'go to definition' it finds it
without any problems.

>
> I can't reproduce this - it appears to work as expected for me.
>
> Have you tried it in a clean project?

How would I 'clean' my project to force the IDE to refresh everything?
Can I turn off that 'feature'?

>
> Dave

Simon

From: David Lowndes on
>When I first open the project it looks ok, I can even compile it.
>But if I make a small change, (delete one character and replace it), then
>the text greys out.

That does sound as though something is confusing the parser.

>> Have you tried it in a clean project?
>How would I 'clean' my project to force the IDE to refresh everything?

No I meant to check the basics as you presented them to us - use a
clean console application and just check that it works as you'd expect
there.

>Can I turn off that 'feature'?

I'd assume it's the Tools, Options, Text Editor, C/C++, Formatting -
"Colorize inactive ..." option.

Dave
From: Simon on
> >When I first open the project it looks ok, I can even compile it.
>>But if I make a small change, (delete one character and replace it), then
>>the text greys out.
>
> That does sound as though something is confusing the parser.

I guess.

>
>>> Have you tried it in a clean project?
>>How would I 'clean' my project to force the IDE to refresh everything?
>
> No I meant to check the basics as you presented them to us - use a
> clean console application and just check that it works as you'd expect
> there.

I'll try that in a minute. But I am sure it will work on a 'simple' project.

>
>>Can I turn off that 'feature'?
>
> I'd assume it's the Tools, Options, Text Editor, C/C++, Formatting -
> "Colorize inactive ..." option.

Ah, one of those tricky, obscure, options again :).

>
> Dave