config.hpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * Copyright 2013, 2017 Andrey Semashev
  3. * Copyright 2017 James E. King, III
  4. *
  5. * Distributed under the Boost Software License, Version 1.0.
  6. * See http://www.boost.org/LICENSE_1_0.txt
  7. */
  8. #ifndef BOOST_WINAPI_CONFIG_HPP_INCLUDED_
  9. #define BOOST_WINAPI_CONFIG_HPP_INCLUDED_
  10. #include <boost/predef/version_number.h>
  11. #include <boost/predef/platform.h>
  12. #if defined(__CYGWIN__)
  13. // Cygwin 64 compiler does not define _WIN64 and instead defines it in a private header. We can't define _WIN64 ourselves because
  14. // the header defines the macro unconditionally and if the user includes both Boost.WinAPI and Cygwin WinAPI headers there will be conflict.
  15. #include <_cygwin.h>
  16. #endif
  17. // BOOST_WINAPI_IS_MINGW indicates that the target Windows SDK is provided by MinGW (http://mingw.org/).
  18. // BOOST_WINAPI_IS_MINGW_W64 indicates that the target Windows SDK is provided by MinGW-w64 (http://mingw-w64.org).
  19. // BOOST_WINAPI_IS_CYGWIN indicates that the target Windows SDK is provided by MinGW variant from Cygwin (https://cygwin.com/).
  20. #if defined(__CYGWIN__)
  21. #define BOOST_WINAPI_IS_CYGWIN
  22. #elif BOOST_PLAT_MINGW
  23. #if defined(__MINGW64_VERSION_MAJOR)
  24. #define BOOST_WINAPI_IS_MINGW_W64
  25. #else
  26. #define BOOST_WINAPI_IS_MINGW
  27. #endif
  28. #endif
  29. // These constants reflect _WIN32_WINNT_* macros from sdkddkver.h
  30. // See also: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx#setting_winver_or__win32_winnt
  31. #define BOOST_WINAPI_VERSION_NT4 0x0400
  32. #define BOOST_WINAPI_VERSION_WIN2K 0x0500
  33. #define BOOST_WINAPI_VERSION_WINXP 0x0501
  34. #define BOOST_WINAPI_VERSION_WS03 0x0502
  35. #define BOOST_WINAPI_VERSION_WIN6 0x0600
  36. #define BOOST_WINAPI_VERSION_VISTA 0x0600
  37. #define BOOST_WINAPI_VERSION_WS08 0x0600
  38. #define BOOST_WINAPI_VERSION_LONGHORN 0x0600
  39. #define BOOST_WINAPI_VERSION_WIN7 0x0601
  40. #define BOOST_WINAPI_VERSION_WIN8 0x0602
  41. #define BOOST_WINAPI_VERSION_WINBLUE 0x0603
  42. #define BOOST_WINAPI_VERSION_WINTHRESHOLD 0x0A00
  43. #define BOOST_WINAPI_VERSION_WIN10 0x0A00
  44. // These constants reflect NTDDI_* macros from sdkddkver.h
  45. #define BOOST_WINAPI_NTDDI_WIN2K 0x05000000
  46. #define BOOST_WINAPI_NTDDI_WIN2KSP1 0x05000100
  47. #define BOOST_WINAPI_NTDDI_WIN2KSP2 0x05000200
  48. #define BOOST_WINAPI_NTDDI_WIN2KSP3 0x05000300
  49. #define BOOST_WINAPI_NTDDI_WIN2KSP4 0x05000400
  50. #define BOOST_WINAPI_NTDDI_WINXP 0x05010000
  51. #define BOOST_WINAPI_NTDDI_WINXPSP1 0x05010100
  52. #define BOOST_WINAPI_NTDDI_WINXPSP2 0x05010200
  53. #define BOOST_WINAPI_NTDDI_WINXPSP3 0x05010300
  54. #define BOOST_WINAPI_NTDDI_WINXPSP4 0x05010400
  55. #define BOOST_WINAPI_NTDDI_WS03 0x05020000
  56. #define BOOST_WINAPI_NTDDI_WS03SP1 0x05020100
  57. #define BOOST_WINAPI_NTDDI_WS03SP2 0x05020200
  58. #define BOOST_WINAPI_NTDDI_WS03SP3 0x05020300
  59. #define BOOST_WINAPI_NTDDI_WS03SP4 0x05020400
  60. #define BOOST_WINAPI_NTDDI_WIN6 0x06000000
  61. #define BOOST_WINAPI_NTDDI_WIN6SP1 0x06000100
  62. #define BOOST_WINAPI_NTDDI_WIN6SP2 0x06000200
  63. #define BOOST_WINAPI_NTDDI_WIN6SP3 0x06000300
  64. #define BOOST_WINAPI_NTDDI_WIN6SP4 0x06000400
  65. #define BOOST_WINAPI_NTDDI_VISTA BOOST_WINAPI_NTDDI_WIN6
  66. #define BOOST_WINAPI_NTDDI_VISTASP1 BOOST_WINAPI_NTDDI_WIN6SP1
  67. #define BOOST_WINAPI_NTDDI_VISTASP2 BOOST_WINAPI_NTDDI_WIN6SP2
  68. #define BOOST_WINAPI_NTDDI_VISTASP3 BOOST_WINAPI_NTDDI_WIN6SP3
  69. #define BOOST_WINAPI_NTDDI_VISTASP4 BOOST_WINAPI_NTDDI_WIN6SP4
  70. #define BOOST_WINAPI_NTDDI_LONGHORN BOOST_WINAPI_NTDDI_VISTA
  71. #define BOOST_WINAPI_NTDDI_WS08 BOOST_WINAPI_NTDDI_WIN6SP1
  72. #define BOOST_WINAPI_NTDDI_WS08SP2 BOOST_WINAPI_NTDDI_WIN6SP2
  73. #define BOOST_WINAPI_NTDDI_WS08SP3 BOOST_WINAPI_NTDDI_WIN6SP3
  74. #define BOOST_WINAPI_NTDDI_WS08SP4 BOOST_WINAPI_NTDDI_WIN6SP4
  75. #define BOOST_WINAPI_NTDDI_WIN7 0x06010000
  76. #define BOOST_WINAPI_NTDDI_WIN7SP1 0x06010100 // Not defined in Windows SDK
  77. #define BOOST_WINAPI_NTDDI_WIN8 0x06020000
  78. #define BOOST_WINAPI_NTDDI_WINBLUE 0x06030000
  79. #define BOOST_WINAPI_NTDDI_WINTHRESHOLD 0x0A000000
  80. #define BOOST_WINAPI_NTDDI_WIN10 0x0A000000
  81. #define BOOST_WINAPI_NTDDI_WIN10_TH2 0x0A000001
  82. #define BOOST_WINAPI_NTDDI_WIN10_RS1 0x0A000002
  83. #define BOOST_WINAPI_NTDDI_WIN10_RS2 0x0A000003
  84. #define BOOST_WINAPI_NTDDI_WIN10_RS3 0x0A000004
  85. #define BOOST_WINAPI_DETAIL_MAKE_NTDDI_VERSION2(x) x##0000
  86. #define BOOST_WINAPI_DETAIL_MAKE_NTDDI_VERSION(x) BOOST_WINAPI_DETAIL_MAKE_NTDDI_VERSION2(x)
  87. #if !defined(BOOST_USE_WINAPI_VERSION)
  88. #if defined(_WIN32_WINNT)
  89. #define BOOST_USE_WINAPI_VERSION _WIN32_WINNT
  90. #elif defined(WINVER)
  91. #define BOOST_USE_WINAPI_VERSION WINVER
  92. #else
  93. // By default use Windows 7 API on compilers that support it and Vista or XP on the others
  94. #if (defined(_MSC_VER) && _MSC_VER < 1500) || defined(BOOST_WINAPI_IS_MINGW)
  95. #define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP
  96. #elif (defined(_MSC_VER) && _MSC_VER < 1600)
  97. #define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WIN6
  98. #else
  99. #define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WIN7
  100. #endif
  101. #endif
  102. #endif
  103. #if !defined(BOOST_USE_NTDDI_VERSION)
  104. #if defined(NTDDI_VERSION)
  105. #define BOOST_USE_NTDDI_VERSION NTDDI_VERSION
  106. // Default to respective Windows version with the latest Service Pack
  107. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WIN2K
  108. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WIN2KSP4
  109. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WINXP
  110. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WINXPSP3
  111. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WS03
  112. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WS03SP2
  113. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WIN6
  114. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WIN6SP2
  115. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WIN7
  116. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WIN7SP1
  117. #elif BOOST_USE_WINAPI_VERSION == BOOST_WINAPI_VERSION_WIN10
  118. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_NTDDI_WIN10_RS3
  119. #else
  120. #define BOOST_USE_NTDDI_VERSION BOOST_WINAPI_DETAIL_MAKE_NTDDI_VERSION(BOOST_USE_WINAPI_VERSION)
  121. #endif
  122. #endif
  123. // Known Windows SDK versions, taken from VER_PRODUCTBUILD macro value defined in ntverp.h.
  124. // These values can be used to compare with BOOST_PLAT_WINDOWS_SDK_VERSION from Boost.Predef.
  125. #define BOOST_WINAPI_WINDOWS_SDK_MSVC71 BOOST_VERSION_NUMBER(0, 0, 3668) // Windows SDK bundled with MSVC 7.1
  126. #define BOOST_WINAPI_WINDOWS_SDK_MSVC8 BOOST_VERSION_NUMBER(0, 0, 3790) // Windows SDK bundled with MSVC 8
  127. #define BOOST_WINAPI_WINDOWS_SDK_6_0 BOOST_VERSION_NUMBER(0, 0, 6000) // Windows SDK 6.0
  128. #define BOOST_WINAPI_WINDOWS_SDK_7_0 BOOST_VERSION_NUMBER(0, 0, 7600) // Windows SDK 7.0, 7.1
  129. #define BOOST_WINAPI_WINDOWS_SDK_8_0 BOOST_VERSION_NUMBER(0, 0, 9200) // Windows SDK 8.0
  130. #define BOOST_WINAPI_WINDOWS_SDK_8_1 BOOST_VERSION_NUMBER(0, 0, 9600) // Windows SDK 8.1
  131. #define BOOST_WINAPI_WINDOWS_SDK_10_0 BOOST_VERSION_NUMBER(0, 0, 10011) // Windows SDK 10.0
  132. // MinGW does not have the ntverp.h header but it defines VER_PRODUCTBUILD in ddk/ntifs.h.
  133. // Cygwin MinGW also defines this version.
  134. #define BOOST_WINAPI_WINDOWS_SDK_MINGW BOOST_VERSION_NUMBER(0, 0, 10000)
  135. // MinGW-w64 defines the same version as the Windows SDK bundled with MSVC 8
  136. #define BOOST_WINAPI_WINDOWS_SDK_MINGW_W64 BOOST_VERSION_NUMBER(0, 0, 3790)
  137. #if !defined(BOOST_USE_WINAPI_FAMILY)
  138. #if defined(WINAPI_FAMILY)
  139. #define BOOST_USE_WINAPI_FAMILY WINAPI_FAMILY
  140. #elif defined(WINAPI_FAMILY_DESKTOP_APP)
  141. // If none is specified, default to a desktop application which is the most
  142. // backwards compatible to previous ways of doing things, if families are even
  143. // defined.
  144. #define BOOST_USE_WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
  145. #endif
  146. #endif
  147. //
  148. // UWP Support
  149. //
  150. // On platforms without windows family partition support it is assumed one
  151. // has all APIs and access is controlled by _WIN32_WINNT or similar mechanisms.
  152. //
  153. // Leveraging Boost.Predef here
  154. //
  155. #if BOOST_PLAT_WINDOWS_UWP
  156. #define BOOST_WINAPI_PARTITION_APP (BOOST_PLAT_WINDOWS_DESKTOP || BOOST_PLAT_WINDOWS_STORE || BOOST_WINAPI_PARTITION_PHONE)
  157. #define BOOST_WINAPI_PARTITION_PC (BOOST_PLAT_WINDOWS_STORE)
  158. #define BOOST_WINAPI_PARTITION_PHONE (BOOST_PLAT_WINDOWS_PHONE)
  159. #define BOOST_WINAPI_PARTITION_SYSTEM (BOOST_PLAT_WINDOWS_SYSTEM)
  160. #define BOOST_WINAPI_PARTITION_SERVER (BOOST_PLAT_WINDOWS_SERVER)
  161. #define BOOST_WINAPI_PARTITION_DESKTOP (BOOST_PLAT_WINDOWS_DESKTOP)
  162. #else // BOOST_PLAT_WINDOWS_UWP
  163. #define BOOST_WINAPI_PARTITION_APP (1)
  164. #define BOOST_WINAPI_PARTITION_PC (1)
  165. #define BOOST_WINAPI_PARTITION_PHONE (1)
  166. #define BOOST_WINAPI_PARTITION_SYSTEM (1)
  167. #define BOOST_WINAPI_PARTITION_SERVER (1)
  168. #define BOOST_WINAPI_PARTITION_DESKTOP (1)
  169. #endif // BOOST_PLAT_WINDOWS_UWP
  170. //
  171. // Windows 8.x SDK defines some items in the DESKTOP partition and then Windows SDK 10.0 defines
  172. // the same items to be in APP or SYSTEM partitions, and APP expands to DESKTOP or PC or PHONE.
  173. // The definition of BOOST_WINAPI_PARTITION_APP_SYSTEM provides a universal way to get this
  174. // right as it is seen in a number of places in the SDK.
  175. //
  176. #define BOOST_WINAPI_PARTITION_APP_SYSTEM \
  177. ( \
  178. ((BOOST_PLAT_WINDOWS_SDK_VERSION >= BOOST_WINAPI_WINDOWS_SDK_10_0) && (BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM)) || \
  179. ((BOOST_PLAT_WINDOWS_SDK_VERSION < BOOST_WINAPI_WINDOWS_SDK_10_0) && BOOST_WINAPI_PARTITION_DESKTOP) \
  180. )
  181. // Simiarly, some other symbols were re-classified as DESKTOP or SYSTEM
  182. #define BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM \
  183. ( \
  184. ((BOOST_PLAT_WINDOWS_SDK_VERSION >= BOOST_WINAPI_WINDOWS_SDK_10_0) && (BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM)) || \
  185. ((BOOST_PLAT_WINDOWS_SDK_VERSION < BOOST_WINAPI_WINDOWS_SDK_10_0) && BOOST_WINAPI_PARTITION_DESKTOP) \
  186. )
  187. #if defined(BOOST_USE_WINDOWS_H) || defined(BOOST_WINAPI_DEFINE_VERSION_MACROS)
  188. // We have to define the version macros so that windows.h provides the necessary symbols
  189. #if !defined(_WIN32_WINNT)
  190. #define _WIN32_WINNT BOOST_USE_WINAPI_VERSION
  191. #endif
  192. #if !defined(WINVER)
  193. #define WINVER BOOST_USE_WINAPI_VERSION
  194. #endif
  195. #if !defined(NTDDI_VERSION)
  196. #define NTDDI_VERSION BOOST_USE_NTDDI_VERSION
  197. #endif
  198. #if !defined(WINAPI_FAMILY) && defined(BOOST_USE_WINAPI_FAMILY)
  199. #define WINAPI_FAMILY BOOST_USE_WINAPI_FAMILY
  200. #endif
  201. #endif
  202. #include <boost/config.hpp>
  203. #ifdef BOOST_HAS_PRAGMA_ONCE
  204. #pragma once
  205. #endif
  206. #endif // BOOST_WINAPI_CONFIG_HPP_INCLUDED_