Aug 012008

Having trouble finding out your VC++ compiler version number? Let me help you out. 🙂 Open command prompt type and type in

cl.exe /?

Relevant part, as shown for me, is pasted here. My current compiler is VC6.

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80×86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Important pieces are in bold. Compiler is a 32-bit one and it’s version is 12.00.8804. So _MSC_VER will be 1200. Also the copyright year is important 1984-1998, this compiler was released in 1998, 1984 tells the year when Microsoft(R) Corp was registered as a company. 😉

So if you want to compile some piece of code just for VC6 compiler then you can add conditional compilation statements likewise…

#if _MSC_VER == 1200
  // Some VC6 specific code

For VC8, above copyright message looks like this for me…

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80×86 Copyright (C) Microsoft Corporation.  All rights reserved.

So _MSC_VER for VC8 will be 1400.

Now you may ask that how can I check full version of my vc++ compiler, for that purpose we have _MSC_FULL_VER macro defined.

#if _MSC_FULL_VER == 140050727
std::cout << "You are using vc8 compiler, version: " << _MSC_FULL_VER; #endif[/sourcecode] Values of _MSC_VER for different VC versions are listed below... VC6 - 1200 VC7 - 1300 VC8 - 1400 VC9 - 1500