visualc.h 3.2 KB

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