Dave's Brain

Browse - programming tips - how to use msc ver

Date: 2010may7
Language: C/C++
Product: Visual C++

Q.  How do I use the _MSC_VER predefined macro?

A.  The help file says:

	Reports the major and minor versions of the compiler.
	For example, 1310 for Microsoft Visual C++ .NET 2003. 1310 represents
	version 13 and a 1.0 point release.

There is code around that seems to think its hex - eg 0x1310.  This WRONG!
(WINVER is like that.)

The simplest way to use it is to test if you are using a Microsoft compiler or not:

	#ifdef _MSC_VER
		// Using some version of Microsoft Visual C++
	#else
		// NOT using some version of Microsoft Visual C++
	#endif

If you need to check the version, do this:

	#if (_MSC_VER >= 1400)
		// This is Visual C++ 8.0 (Visual Studio 2005)
	#elif (_MSC_VER >= 1310)
		// This is Visual C++ 7.1 (Visual Studio .NET 2003)
	#elif (_MSC_VER >= 1300)
		// This is Visual C++ 7.0 (Visual Studio .NET 2002)
	#else
		// This is Visual C++ 6.0
	#endif
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: