VS2008 weird behavior regarding greyed out code in preprocessor directives
-
I have a VS2008 solution with different C++ projects. It is a legacy solution which is still in production and has to be maintained and enhanced in the next years. Some of the classes are usesd in different projects of the solution. Each solution has a compiler switch that tells the compiler which project is currently compiled. In code you will often find something (ugly) like: Declaration:
class FooClass
{
public:
void FncA();
#ifdef APP_1_EXE
void FncB();
#endif#ifdef APP_2_EXE
void FncC();
#endif
};Implementation:
void FooClass::FncA()
{
// do something
#ifdef APP_1_EXE
// do special stuff for APP 1
#endif
}#ifdef APP_1_EXE
void FooClass::FncB()
{
}#endif
#ifdef APP_2_EXE
void FooClass::FncC()
{
}
#endifNow I have the behavior that APP_1 is active, but in the header file the code is greyed out and in the cpp module code is not greyed out. Even if I right click on the declarations in the header file, I cannot select "goto references" or "goto declaration" in the conext menue. In the class explorer the methods are inaccessible even if the compiler switch is set. For me it looks like VS2008 does not recognize the current active project. Any ideas or hints how to solve the problem? Maybe a good google query? After two days I'm out of ideas :-( Thx Andy PS: The problematic behaviour resides already for a while but it became massiv after I started to refactor and splitted the main header file which contained almost all class declarations into seperate header files. Now each class has it's own header file and it's own implementation file (liek FooClass.h and FooClass.cpp) I also know that it would be better to have a base class an use project specific derived classes instead of preprocessor switches but as I explained at the top: It's legacy code and I'm just at the beginning of the refactoring process.
-
I have a VS2008 solution with different C++ projects. It is a legacy solution which is still in production and has to be maintained and enhanced in the next years. Some of the classes are usesd in different projects of the solution. Each solution has a compiler switch that tells the compiler which project is currently compiled. In code you will often find something (ugly) like: Declaration:
class FooClass
{
public:
void FncA();
#ifdef APP_1_EXE
void FncB();
#endif#ifdef APP_2_EXE
void FncC();
#endif
};Implementation:
void FooClass::FncA()
{
// do something
#ifdef APP_1_EXE
// do special stuff for APP 1
#endif
}#ifdef APP_1_EXE
void FooClass::FncB()
{
}#endif
#ifdef APP_2_EXE
void FooClass::FncC()
{
}
#endifNow I have the behavior that APP_1 is active, but in the header file the code is greyed out and in the cpp module code is not greyed out. Even if I right click on the declarations in the header file, I cannot select "goto references" or "goto declaration" in the conext menue. In the class explorer the methods are inaccessible even if the compiler switch is set. For me it looks like VS2008 does not recognize the current active project. Any ideas or hints how to solve the problem? Maybe a good google query? After two days I'm out of ideas :-( Thx Andy PS: The problematic behaviour resides already for a while but it became massiv after I started to refactor and splitted the main header file which contained almost all class declarations into seperate header files. Now each class has it's own header file and it's own implementation file (liek FooClass.h and FooClass.cpp) I also know that it would be better to have a base class an use project specific derived classes instead of preprocessor switches but as I explained at the top: It's legacy code and I'm just at the beginning of the refactoring process.
-
You may just need to rebuild the projects as moving files and changing headers takes some time to be recognised. Try a Clean and Build of your complete solution.
Thx for the hint. Unfortunately it does not help. I also tried to delete the ncb file of the solution. It has no effect, either. At the moment I have two assumptions: 1) It has to do something with the size of the source files. There are several files with more (!) than 10k lines (no joke! As I told in my first post: Lot's of legacy stuff from more then 15 years) 2) Maybe something goes wrong with the bsc files (browse source) Regards, Andy PS: At the moment I'm at the beginning of a huge refactoring process. It can only be done step by step. Otherwise it (and I) will loose the acceptance of the colleages. They are usesd to work with these huge files...
-
Thx for the hint. Unfortunately it does not help. I also tried to delete the ncb file of the solution. It has no effect, either. At the moment I have two assumptions: 1) It has to do something with the size of the source files. There are several files with more (!) than 10k lines (no joke! As I told in my first post: Lot's of legacy stuff from more then 15 years) 2) Maybe something goes wrong with the bsc files (browse source) Regards, Andy PS: At the moment I'm at the beginning of a huge refactoring process. It can only be done step by step. Otherwise it (and I) will loose the acceptance of the colleages. They are usesd to work with these huge files...
-
Sorry but I have no other suggestions. Whenever I have seen this it has always cleared up after a rebuild.