Ran into a problem in MSVC 2008 today that I cannot explain.
Take the following sample code:
MYDLL_EXPORTS is defined in the project pre-processor settings.
#define MYDLL_DECL __declspec(dllexport)
#define MYDLL_DECL __declspec(dllimport)
The problem I ran into is that even when MYDLL_EXPORTS was defined MSVC 2008 greyed out the first define and not the second. When I tested it and added #define MYDLL_EXPORTS prior to the #ifdef it then would not compile saying that MYDLL_EXPORTS was a duplicate define. After removing the #define now MSVS 2008 has greyed out the #ifdef line.
What in the world? I have 9 other DLL projects using the same type of mechanism in the same solution and they all work. However for this one file only it is saying that the MYDLL_EXPORTS is not defined and it is not exporting the functions so I get unresolved externals.
And this is even stranger. When I load the project up by itself the define works and everything is normal and the second define is greyed out like one would expect. Even stranger yet is that any macros that are after the first #ifdef do not work. No greying out, nothing - almost as if the pre-processor is ignoring them.
- Deleting all build files
- Deleting the ncb
- Removing the project from the solution and adding it back in
- Closing and re-starting MSVS
- Rebooting the PC and restarting MSVS
I was changing dependencies prior to this happening so I'm wondering if MSVS messed up the solution file (perhaps duplicate entries or something) that is hosing the pre-processor. I've done a search and examined the properties for all projects in the sln for MYDLL_EXPORTS to see if one of them #undef it or did something odd. Nothing. It is not being used anywhere else except in the file it is supposed to be in. Looks like I'm going to be doing a diff on solution files....yay me.
What is it with the pre-processor ills for me this week?