Search This Blog

Loading...

Tuesday, August 5, 2008

The Macro to Check Microsoft Compiler Version in C++

Here's how to check the Microsoft Compiler's Version in C++ using macro ( preprocessor directive):


#if _MSC_VER == 1500 // Visual C++ 2008
#elif _MSC_VER == 1400 //Visual C++ 2005
#elif _MSC_VER == 1310 //Visual C++. Net 2003
#elif _MSC_VER == 1300 //Visual C++.Net 2002
#elif _MSC_VER == 1200 //Microsoft Visual C++ 6.0
#elif _MSC_VER == 1100 //MIcrsoft Visual C++ 5.0
#endif



I don't know the macro for older MS compilers, anyone knows?

2 comments:

Hannes said...

1100 is supposed to be 5.0, but who cares any more ...

Soon Hui said...

Thanks hannes, at least I do.