Tuesday, October 6, 2009

Microsoft Visual Studio 2008 Editor blunder

I encounter a very frustating bug in Microsoft Visual Studio 2008.

When you would like to share a code between project (and somehow the flow of the program is slightly different for these two project), I use the #define, #ifdef as the indicator for the compiler.

I have more than one project in the solution. In project A, I defined "_BLABLABLA" in the project property "Preprocessor Definitions" and in the project B, I do not define this. And in these two project, a file (test.cpp, code is included below) is included to both of the project (same file for both project). Guess what happen?

test.cpp
.
.
.
#ifdef _BLABLABLA
printf ("Testing 1");
#elseif
printf ("Testing 2");
#endif
.
.
.


The compiler take this #define and behaves correctly. Unfortunately Microsoft Visual Studio Editor do not.

You can try to navigate thru the Solution Explorer and go to project B and locate the test.cpp and double-click on the file. The file is open and if you take a look, the line contains printf ("Testing 2"); will be greyed out.... But why?????

I have no idea currently..... (I believe this is a bug in Microsoft Visual Studio 2008)

Actually it is ok, but the IntelliSense is not working on the greyed out source code, so you are stuck...

No comments:

Post a Comment