4

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?

Hoppy
  • 720
  • 2
  • 12
  • 24
  • That question/answer is for a different issue. My question is related to Visual Studio's Property Page Macros. – Hoppy May 11 '15 at 05:43

3 Answers3

7

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

KeatsPeeks
  • 19,126
  • 5
  • 52
  • 83
  • Good point about different (incompatible) versions of project files for VS2005 and VS2008. – Pavel Minaev Dec 08 '09 at 18:04
  • 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 Dec 09 '09 at 10:58
  • then i'm afraid I don't know how to achieve that – KeatsPeeks Dec 11 '09 at 17:00
2

You could use the property page macros $(PlatformToolsetVersion) or $(PlatformToolset) For vc++ 2012, for example, $(PlatformToolsetVersion) resolves to "110" and $(PlatformToolset) resolves to "v110". So adding "vc$(PlatformToolsetVersion)" to your path would add "vc110" under vc11 or "vc90" under vc9.

myodo
  • 36
  • 1
  • Not sure if this was available in VS2005, but I am working with v90/v100/v110 now so this is perfect. It just took 4 years to get the answer :) – Hoppy Feb 18 '14 at 23:25
1

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
  • 733,204
  • 149
  • 1,241
  • 1,454
  • 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 Dec 08 '09 at 17:23