1 | /* |
2 | Copyright Rene Rivera 2008-2015 |
3 | Distributed under the Boost Software License, Version 1.0. |
4 | (See accompanying file LICENSE_1_0.txt or copy at |
5 | http://www.boost.org/LICENSE_1_0.txt) |
6 | */ |
7 | |
8 | #ifndef BOOST_PREDEF_COMPILER_VISUALC_H |
9 | #define BOOST_PREDEF_COMPILER_VISUALC_H |
10 | |
11 | /* Other compilers that emulate this one need to be detected first. */ |
12 | |
13 | #include <boost/predef/compiler/clang.h> |
14 | |
15 | #include <boost/predef/version_number.h> |
16 | #include <boost/predef/make.h> |
17 | |
18 | /* tag::reference[] |
19 | = `BOOST_COMP_MSVC` |
20 | |
21 | http://en.wikipedia.org/wiki/Visual_studio[Microsoft Visual C/{CPP}] compiler. |
22 | Version number available as major, minor, and patch. |
23 | |
24 | [options="header"] |
25 | |=== |
26 | | {predef_symbol} | {predef_version} |
27 | |
28 | | `+_MSC_VER+` | {predef_detection} |
29 | |
30 | | `+_MSC_FULL_VER+` | V.R.P |
31 | | `+_MSC_VER+` | V.R.0 |
32 | |=== |
33 | |
34 | NOTE: Release of Visual Studio after 2015 will no longer be identified |
35 | by Boost Predef as the marketing version number. Instead we use the |
36 | compiler version number directly, i.e. the _MSC_VER number. |
37 | */ // end::reference[] |
38 | |
39 | #define BOOST_COMP_MSVC BOOST_VERSION_NUMBER_NOT_AVAILABLE |
40 | |
41 | #if defined(_MSC_VER) |
42 | # if !defined (_MSC_FULL_VER) |
43 | # define BOOST_COMP_MSVC_BUILD 0 |
44 | # else |
45 | /* how many digits does the build number have? */ |
46 | # if _MSC_FULL_VER / 10000 == _MSC_VER |
47 | /* four digits */ |
48 | # define BOOST_COMP_MSVC_BUILD (_MSC_FULL_VER % 10000) |
49 | # elif _MSC_FULL_VER / 100000 == _MSC_VER |
50 | /* five digits */ |
51 | # define BOOST_COMP_MSVC_BUILD (_MSC_FULL_VER % 100000) |
52 | # else |
53 | # error "Cannot determine build number from _MSC_FULL_VER" |
54 | # endif |
55 | # endif |
56 | /* |
57 | VS2014 was skipped in the release sequence for MS. Which |
58 | means that the compiler and VS product versions are no longer |
59 | in sync. Hence we need to use different formulas for |
60 | mapping from MSC version to VS product version. |
61 | |
62 | VS2017 is a total nightmare when it comes to version numbers. |
63 | Hence to avoid arguments relating to that both present and |
64 | future.. Any version after VS2015 will use solely the compiler |
65 | version, i.e. cl.exe, as the version number here. |
66 | */ |
67 | # if (_MSC_VER > 1900) |
68 | # define BOOST_COMP_MSVC_DETECTION BOOST_VERSION_NUMBER(\ |
69 | _MSC_VER/100,\ |
70 | _MSC_VER%100,\ |
71 | BOOST_COMP_MSVC_BUILD) |
72 | # elif (_MSC_VER >= 1900) |
73 | # define BOOST_COMP_MSVC_DETECTION BOOST_VERSION_NUMBER(\ |
74 | _MSC_VER/100-5,\ |
75 | _MSC_VER%100,\ |
76 | BOOST_COMP_MSVC_BUILD) |
77 | # else |
78 | # define BOOST_COMP_MSVC_DETECTION BOOST_VERSION_NUMBER(\ |
79 | _MSC_VER/100-6,\ |
80 | _MSC_VER%100,\ |
81 | BOOST_COMP_MSVC_BUILD) |
82 | # endif |
83 | #endif |
84 | |
85 | #ifdef BOOST_COMP_MSVC_DETECTION |
86 | # if defined(BOOST_PREDEF_DETAIL_COMP_DETECTED) |
87 | # define BOOST_COMP_MSVC_EMULATED BOOST_COMP_MSVC_DETECTION |
88 | # else |
89 | # undef BOOST_COMP_MSVC |
90 | # define BOOST_COMP_MSVC BOOST_COMP_MSVC_DETECTION |
91 | # endif |
92 | # define BOOST_COMP_MSVC_AVAILABLE |
93 | # include <boost/predef/detail/comp_detected.h> |
94 | #endif |
95 | |
96 | #define BOOST_COMP_MSVC_NAME "Microsoft Visual C/C++" |
97 | |
98 | #endif |
99 | |
100 | #include <boost/predef/detail/test.h> |
101 | BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_MSVC,BOOST_COMP_MSVC_NAME) |
102 | |
103 | #ifdef BOOST_COMP_MSVC_EMULATED |
104 | #include <boost/predef/detail/test.h> |
105 | BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_MSVC_EMULATED,BOOST_COMP_MSVC_NAME) |
106 | #endif |
107 | |