Is there any way to know if I'm compiling under a specific Microsoft Visual Studio version?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
相关文章
- How to show location of errors, references to memb
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- How to track MongoDB requests from a console appli
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
By using the
_MSC_VER
macro.In visual studio, go to help | about and look at the version of Visual Studio that you're using to compile your app.
This is a little old but should get you started:
_MSC_VER
and possibly_MSC_FULL_VER
is what you need. You can also examine visualc.hpp in any recent boost install for some usage examples.Some values for the more recent versions of the compiler are:
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 here. Starting recently, Visual Studio will start updating its ranges monotonically, meaning you should check ranges, rather than exact compiler values.
cl.exe /?
will give a hint of the used version, e.g.: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
<compiler-major-version>.00.<build-number>
, where 00 is the minor number. So_MSC_VER
will evaluate to<major-version><minor-version>
.You can use code like this:
It appears updates between successive releases of the compiler, have not modified the
compiler-minor-version
, so the following code is not required:Access to more detailed versioning information (such as compiler build number) can be found using other builtin pre-processor variables here.
As a more general answer http://sourceforge.net/p/predef/wiki/Home/ maintains a list of macros for detecting specicic compilers, operating systems, architectures, standards and more.