views:

240

answers:

2

I am in the process of migrating our VC++ project from Visual Studio 2005 (VC8) to Visual Studio 2008 (VC9). Some of the projects in the solution have paths to third party libraries in their 'Additional Library Directories' field in the project settings. The paths look something like this:
..\SomeLibrary\Lib\vc9\x86

It would be really useful if I could use one of Visual Studio's "Property Page Macros" to substitute for the compiler version, in much the same way as I can use $(ConfigurationName) to substitue for "Debug" or "Release". Something like the following would be perfect:
..\SomeLibrary\Lib\$(CompilerVersion)\x86

Unfortunately, I can't find an appropriate macro.

Please note that when I say 'macro' I am refering to Visual Studio's "Property Page Macros", not C/C++ preprocessor macros. As far as I am aware you can't use preprocessor directives in the project settings.

Does anyone know of a way to do this?

+1  A: 

Have you tried _MSC_VER. For Microsoft`s C++ compiler this will give the major and minor version number of the compiler. It could be used as the delimeter.

JaredPar
Thanks, but I was looking for some way of doing this through the visual studio project settings. I have edited the original post to make this clearer.
Hoppy
+2  A: 

Use _MSC_VER:

#ifndef _MSC_VER
  // not VC++
#elif _MSC_VER < 1400
  // older than VC++ 2005
#elif _MSC_VER < 1500
  // VC++ 2005
#elif _MSC_VER < 1600
  // VC++ 2008
#elif _MSC_VER < 1700
  // VC++ 2010
#else
  // Future versions
#endif

For a more complicated example, see how boost is dealing with VC++ versions here

Edit: ok so I understand that's not exactly what you need. But if you're using different versions of Visual Studio, then you should have different project files as well, so I don't see where the problem lies.

Samuel_xL
Good point about different (incompatible) versions of project files for VS2005 and VS2008.
Pavel Minaev
I have been tasked with getting the product ready to build under VS2008. Unfortunately, the rest of my team is not yet ready to move to VS2008, so I cannot convert the projects and commit them to our source control system.At the moment, the only part of the code which needs to be changed to work under VS2008 is the library paths. It would be neat if there was a property page macro which I could use for the compiler version - then I could just download the team's source code, convert the projects (a matter of seconds) and perform my development/testing/whatever in VS2008.
Hoppy
then i'm afraid I don't know how to achieve that
Samuel_xL