views:

52

answers:

2

My project has a bunch of #ifdefs. The macros used by these #ifdefs are usually passed through the command line using the '/D' option to get different build configurations. Visual studio incorrectly assumes that these macros are not defined and greys out the code blocks present inside these #ifdefs. The problem is not syntax highlighting - I can turn the grayed out code to colored code from Options; the main issue is that I am not able to go to the function definition of any functions present inside that #ifdef. I tried reading about Visual Studio hint files but that didn't work for me.

Can anyone help me with this issue? I am using Visual Studio 2008.

A: 

If you're not debugging, and you're just trying to get intellisense or whatever to react, you can always just throw up a quick #define to force the IDE to behave.

Seems you have a similar problem as this fellow:

http://stackoverflow.com/questions/3515169/can-intellisense-be-enabled-in-vs2008-within-preprocessor-directive-blocks-like

Nate
That is one solution, but there are a bunch of #ifdefs, not just one, and they are scattered around. So I would like to have get a better solution that this.
Ashwin
+1  A: 

Did you define several kinds of builds within VS as Configurations like Debug, Release, or are you building with makefiles? If you haven't taught VS about your /D options then I guess it can't help you. But you should be able to set up Preprocessor Definitions under project properties (Configuration Properties, C/C++, Preprocessor) to get the effect you want, right?

Kate Gregory
I am building with makefiles. And I tried following instructions given here (http://msdn.microsoft.com/en-us/library/ms173379%28VS.80%29.aspx). I instructed VS to enable a macro using /DMACRO=1 in the Preprocessor Definitions under Configuration Properties->NMake->Intellisense. Closed the solution, deleted .ncb file, reopened the solution, let Intellisense run and cleaned and rebuilt the solution. Things still don't seem to work.
Ashwin
@Ashwin - you tagged this [vs2010]. It doesn't use the .ncb file anymore, its .sdf now. Wrong tag or wrong file?
Hans Passant
@Hans my thoughts exactly
Kate Gregory
Sorry Hans, This is VS2008. My bad. Changing tag...
Ashwin