<p>Is there any way to know if I'm compiling under a specific Microsoft Visual Studio version?</p>

[{'answer_id': 70021, 'author': 'Haacked', 'author_id': 598, 'author_profile': 'https://Stackoverflow.com/users/598', 'pm_score': -1, 'selected': False, 'text': "<p>In visual studio, go to help | about and look at the version of Visual Studio that you're using to compile your app.</p>\n"}, {'answer_id': 70028, 'author': 'DJ Capelis', 'author_id': 10943, 'author_profile': 'https://Stackoverflow.com/users/10943', 'pm_score': 4, 'selected': False, 'text': '<p>_MSC_VER should be defined to a specific version number.  You can either #ifdef on it, or you can use the actual define and do a runtime test.  (If for some reason you wanted to run different code based on what compiler it was compiled with?  Yeah, probably you were looking for the #ifdef. :))</p>\n'}, {'answer_id': 70041, 'author': 'Jeff Hubbard', 'author_id': 8844, 'author_profile': 'https://Stackoverflow.com/users/8844', 'pm_score': 3, 'selected': False, 'text': '<p>By using the <code>_MSC_VER</code> macro.</p>\n'}, {'answer_id': 70630, 'author': 'jilles de wit', 'author_id': 7531, 'author_profile': 'https://Stackoverflow.com/users/7531', 'pm_score': 10, 'selected': True, 'text': '<p><code>_MSC_VER</code> and possibly <code>_MSC_FULL_VER</code> is what you need. You can also examine <a href="https://www.boost.org/doc/libs/master/boost/config/compiler/visualc.hpp" rel="noreferrer">visualc.hpp</a> in any recent boost install for some usage examples.</p>\n\n<p>Some values for the more recent versions of the compiler are:</p>\n\n<pre><code>MSVC++ 14.24 _MSC_VER == 1924 (Visual Studio 2019 version 16.4)\nMSVC++ 14.23 _MSC_VER == 1923 (Visual Studio 2019 version 16.3)\nMSVC++ 14.22 _MSC_VER == 1922 (Visual Studio 2019 version 16.2)\nMSVC++ 14.21 _MSC_VER == 1921 (Visual Studio 2019 version 16.1)\nMSVC++ 14.2  _MSC_VER == 1920 (Visual Studio 2019 version 16.0)\nMSVC++ 14.16 _MSC_VER == 1916 (Visual Studio 2017 version 15.9)\nMSVC++ 14.15 _MSC_VER == 1915 (Visual Studio 2017 version 15.8)\nMSVC++ 14.14 _MSC_VER == 1914 (Visual Studio 2017 version 15.7)\nMSVC++ 14.13 _MSC_VER == 1913 (Visual Studio 2017 version 15.6)\nMSVC++ 14.12 _MSC_VER == 1912 (Visual Studio 2017 version 15.5)\nMSVC++ 14.11 _MSC_VER == 1911 (Visual Studio 2017 version 15.3)\nMSVC++ 14.1  _MSC_VER == 1910 (Visual Studio 2017 version 15.0)\nMSVC++ 14.0  _MSC_VER == 1900 (Visual Studio 2015 version 14.0)\nMSVC++ 12.0  _MSC_VER == 1800 (Visual Studio 2013 version 12.0)\nMSVC++ 11.0  _MSC_VER == 1700 (Visual Studio 2012 version 11.0)\nMSVC++ 10.0  _MSC_VER == 1600 (Visual Studio 2010 version 10.0)\nMSVC++ 9.0   _MSC_FULL_VER == 150030729 (Visual Studio 2008, SP1)\nMSVC++ 9.0   _MSC_VER == 1500 (Visual Studio 2008 version 9.0)\nMSVC++ 8.0   _MSC_VER == 1400 (Visual Studio 2005 version 8.0)\nMSVC++ 7.1   _MSC_VER == 1310 (Visual Studio .NET 2003 version 7.1)\nMSVC++ 7.0   _MSC_VER == 1300 (Visual Studio .NET 2002 version 7.0)\nMSVC++ 6.0   _MSC_VER == 1200 (Visual Studio 6.0 version 6.0)\nMSVC++ 5.0   _MSC_VER == 1100 (Visual Studio 97 version 5.0)\n</code></pre>\n\n<p>The version number above of course refers to the major version of your Visual studio you see in the about box, not to the year in the name.  A thorough list can be found <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering" rel="noreferrer">here</a>. <a href="https://blogs.msdn.microsoft.com/vcblog/2016/10/05/visual-c-compiler-version/" rel="noreferrer">Starting recently</a>, Visual Studio will start updating its ranges monotonically, meaning you should check ranges, rather than exact compiler values.</p>\n\n<p><code>cl.exe /?</code> will give a hint of the used version, e.g.:</p>\n\n<pre><code>c:\\program files (x86)\\microsoft visual studio 11.0\\vc\\bin&gt;cl /?\nMicrosoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86\n.....\n</code></pre>\n'}, {'answer_id': 81262, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>This is a little old but should get you started:</p>\n\n<pre><code>//******************************************************************************\n// Automated platform detection\n//******************************************************************************\n\n// _WIN32 is used by\n// Visual C++\n#ifdef _WIN32\n#define __NT__\n#endif\n\n// Define __MAC__ platform indicator\n#ifdef macintosh\n#define __MAC__\n#endif\n\n// Define __OSX__ platform indicator\n#ifdef __APPLE__\n#define __OSX__\n#endif\n\n// Define __WIN16__ platform indicator \n#ifdef _Windows_\n#ifndef __NT__\n#define __WIN16__\n#endif\n#endif\n\n// Define Windows CE platform indicator\n#ifdef WIN32_PLATFORM_HPCPRO\n#define __WINCE__\n#endif\n\n#if (_WIN32_WCE == 300) // for Pocket PC\n#define __POCKETPC__\n#define __WINCE__\n//#if (_WIN32_WCE == 211) // for Palm-size PC 2.11 (Wyvern)\n//#if (_WIN32_WCE == 201) // for Palm-size PC 2.01 (Gryphon)  \n//#ifdef WIN32_PLATFORM_HPC2000 // for H/PC 2000 (Galileo)\n#endif\n</code></pre>\n'}, {'answer_id': 3786113, 'author': 'display101', 'author_id': 167899, 'author_profile': 'https://Stackoverflow.com/users/167899', 'pm_score': 6, 'selected': False, 'text': '<p>Yep _MSC_VER is the macro that\'ll get you the compiler version.  The last number of releases of Visual C++ have been of the form <code>&lt;compiler-major-version&gt;.00.&lt;build-number&gt;</code>, where 00 is the minor number.  So <code>_MSC_VER</code> will evaluate to <code>&lt;major-version&gt;&lt;minor-version&gt;</code>.</p>\n\n<p>You can use code like this:</p>\n\n<pre><code>#if (_MSC_VER == 1500)\n   // ... Do VC9/Visual Studio 2008 specific stuff\n#elif (_MSC_VER == 1600)\n   // ... Do VC10/Visual Studio 2010 specific stuff\n#elif (_MSC_VER == 1700)\n   // ... Do VC11/Visual Studio 2012 specific stuff\n#endif\n</code></pre>\n\n<p>It appears updates between successive releases of the compiler, have not modified the <code>compiler-minor-version</code>, so the following code is not required:</p>\n\n<pre><code>#if (_MSC_VER &gt;= 1500 &amp;&amp; _MSC_VER &lt;= 1600)\n   // ... Do VC9/Visual Studio 2008 specific stuff\n#endif\n</code></pre>\n\n<p>Access to more detailed versioning information (such as compiler build number) can be found using other builtin pre-processor variables <a href="http://msdn.microsoft.com/en-us/library/b0084kay.aspx" rel="noreferrer">here</a>.</p>\n'}, {'answer_id': 16699310, 'author': 'Clifford', 'author_id': 168986, 'author_profile': 'https://Stackoverflow.com/users/168986', 'pm_score': 2, 'selected': False, 'text': '<p>As a more general answer <a href="http://sourceforge.net/p/predef/wiki/Home/" rel="nofollow">http://sourceforge.net/p/predef/wiki/Home/</a> maintains a list of macros for detecting specicic compilers, operating systems, architectures, standards and more.</p>\n'}]
['https://Stackoverflow.com/questions/70013', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11234/']