Visual Studio 2005 Preprocessor #defines not being inherited

So I come across a situation where I'd like to modify a set of macros based on the project that has included a given header file.


Ugly background - Migrating code from visual studio 6 to visual studio 2005 in pieces.  Some common pieces are still in vc6, which used a compiler that didn't have the extremely NIFTY variadic macros feature introduced in the VC++ compiler in VS2005.  Variadic Macros = macros that accept a variable number of arguments.


Anyway, so I have defined my preprocessor #define at the project level but for some reason the code keeps running as though the #define isn't defined!  If I manually include a #define ... then the code picks it up (depending on where the manual #define is placed).  Am I running up against the "30 preprocessor defines via /D" compiler limitation?  No, a quick look at the command-line shows fewer than 10 in total.


Turns out that because this particular project was migrated from Visual Studio 2003 a wonderful $(NoInherit) tag was added to the compiler call for each file inside the .vcproj file.  Of course this tag isn't exposed through the UI.  Googling revealed that $(NoInherit) did exactly what it sounded like - it inhibits inheriting of the corresponding project level property.  In this case, it was preventing my project level #define from propagating to the compilation command (cl.exe).



No comments:

Post a Comment