visualc.h 3.2 KB

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