workaround.hpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_CONFIG_WORKAROUND_HPP
  6. #define BOOST_CONFIG_WORKAROUND_HPP
  7. // Compiler/library version workaround macro
  8. //
  9. // Usage:
  10. //
  11. // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  12. // // workaround for eVC4 and VC6
  13. // ... // workaround code here
  14. // #endif
  15. //
  16. // When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
  17. // first argument must be undefined or expand to a numeric
  18. // value. The above expands to:
  19. //
  20. // (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300
  21. //
  22. // When used for workarounds that apply to the latest known version
  23. // and all earlier versions of a compiler, the following convention
  24. // should be observed:
  25. //
  26. // #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
  27. //
  28. // The version number in this case corresponds to the last version in
  29. // which the workaround was known to have been required. When
  30. // BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
  31. // BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
  32. // the workaround for any version of the compiler. When
  33. // BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
  34. // error will be issued if the compiler version exceeds the argument
  35. // to BOOST_TESTED_AT(). This can be used to locate workarounds which
  36. // may be obsoleted by newer versions.
  37. #ifndef BOOST_STRICT_CONFIG
  38. #include <boost/config.hpp>
  39. #ifndef __BORLANDC__
  40. #define __BORLANDC___WORKAROUND_GUARD 1
  41. #else
  42. #define __BORLANDC___WORKAROUND_GUARD 0
  43. #endif
  44. #ifndef __CODEGEARC__
  45. #define __CODEGEARC___WORKAROUND_GUARD 1
  46. #else
  47. #define __CODEGEARC___WORKAROUND_GUARD 0
  48. #endif
  49. #ifndef BOOST_BORLANDC
  50. #define BOOST_BORLANDC_WORKAROUND_GUARD 1
  51. #else
  52. #define BOOST_BORLANDC_WORKAROUND_GUARD 0
  53. #endif
  54. #ifndef BOOST_CODEGEARC
  55. #define BOOST_CODEGEARC_WORKAROUND_GUARD 1
  56. #else
  57. #define BOOST_CODEGEARC_WORKAROUND_GUARD 0
  58. #endif
  59. #ifndef BOOST_EMBTC
  60. #define BOOST_EMBTC_WORKAROUND_GUARD 1
  61. #else
  62. #define BOOST_EMBTC_WORKAROUND_GUARD 0
  63. #endif
  64. #ifndef _MSC_VER
  65. #define _MSC_VER_WORKAROUND_GUARD 1
  66. #else
  67. #define _MSC_VER_WORKAROUND_GUARD 0
  68. #endif
  69. #ifndef _MSC_FULL_VER
  70. #define _MSC_FULL_VER_WORKAROUND_GUARD 1
  71. #else
  72. #define _MSC_FULL_VER_WORKAROUND_GUARD 0
  73. #endif
  74. #ifndef BOOST_MSVC
  75. #define BOOST_MSVC_WORKAROUND_GUARD 1
  76. #else
  77. #define BOOST_MSVC_WORKAROUND_GUARD 0
  78. #endif
  79. #ifndef BOOST_MSVC_FULL_VER
  80. #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1
  81. #else
  82. #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0
  83. #endif
  84. #ifndef __GNUC__
  85. #define __GNUC___WORKAROUND_GUARD 1
  86. #else
  87. #define __GNUC___WORKAROUND_GUARD 0
  88. #endif
  89. #ifndef __GNUC_MINOR__
  90. #define __GNUC_MINOR___WORKAROUND_GUARD 1
  91. #else
  92. #define __GNUC_MINOR___WORKAROUND_GUARD 0
  93. #endif
  94. #ifndef __GNUC_PATCHLEVEL__
  95. #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 1
  96. #else
  97. #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 0
  98. #endif
  99. #ifndef BOOST_GCC
  100. #define BOOST_GCC_WORKAROUND_GUARD 1
  101. #define BOOST_GCC_VERSION_WORKAROUND_GUARD 1
  102. #else
  103. #define BOOST_GCC_WORKAROUND_GUARD 0
  104. #define BOOST_GCC_VERSION_WORKAROUND_GUARD 0
  105. #endif
  106. #ifndef BOOST_XLCPP_ZOS
  107. #define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 1
  108. #else
  109. #define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 0
  110. #endif
  111. #ifndef __IBMCPP__
  112. #define __IBMCPP___WORKAROUND_GUARD 1
  113. #else
  114. #define __IBMCPP___WORKAROUND_GUARD 0
  115. #endif
  116. #ifndef __SUNPRO_CC
  117. #define __SUNPRO_CC_WORKAROUND_GUARD 1
  118. #else
  119. #define __SUNPRO_CC_WORKAROUND_GUARD 0
  120. #endif
  121. #ifndef __DECCXX_VER
  122. #define __DECCXX_VER_WORKAROUND_GUARD 1
  123. #else
  124. #define __DECCXX_VER_WORKAROUND_GUARD 0
  125. #endif
  126. #ifndef __MWERKS__
  127. #define __MWERKS___WORKAROUND_GUARD 1
  128. #else
  129. #define __MWERKS___WORKAROUND_GUARD 0
  130. #endif
  131. #ifndef __EDG__
  132. #define __EDG___WORKAROUND_GUARD 1
  133. #else
  134. #define __EDG___WORKAROUND_GUARD 0
  135. #endif
  136. #ifndef __EDG_VERSION__
  137. #define __EDG_VERSION___WORKAROUND_GUARD 1
  138. #else
  139. #define __EDG_VERSION___WORKAROUND_GUARD 0
  140. #endif
  141. #ifndef __HP_aCC
  142. #define __HP_aCC_WORKAROUND_GUARD 1
  143. #else
  144. #define __HP_aCC_WORKAROUND_GUARD 0
  145. #endif
  146. #ifndef __hpxstd98
  147. #define __hpxstd98_WORKAROUND_GUARD 1
  148. #else
  149. #define __hpxstd98_WORKAROUND_GUARD 0
  150. #endif
  151. #ifndef _CRAYC
  152. #define _CRAYC_WORKAROUND_GUARD 1
  153. #else
  154. #define _CRAYC_WORKAROUND_GUARD 0
  155. #endif
  156. #ifndef __DMC__
  157. #define __DMC___WORKAROUND_GUARD 1
  158. #else
  159. #define __DMC___WORKAROUND_GUARD 0
  160. #endif
  161. #ifndef MPW_CPLUS
  162. #define MPW_CPLUS_WORKAROUND_GUARD 1
  163. #else
  164. #define MPW_CPLUS_WORKAROUND_GUARD 0
  165. #endif
  166. #ifndef __COMO__
  167. #define __COMO___WORKAROUND_GUARD 1
  168. #else
  169. #define __COMO___WORKAROUND_GUARD 0
  170. #endif
  171. #ifndef __COMO_VERSION__
  172. #define __COMO_VERSION___WORKAROUND_GUARD 1
  173. #else
  174. #define __COMO_VERSION___WORKAROUND_GUARD 0
  175. #endif
  176. #ifndef __INTEL_COMPILER
  177. #define __INTEL_COMPILER_WORKAROUND_GUARD 1
  178. #else
  179. #define __INTEL_COMPILER_WORKAROUND_GUARD 0
  180. #endif
  181. #ifndef __ICL
  182. #define __ICL_WORKAROUND_GUARD 1
  183. #else
  184. #define __ICL_WORKAROUND_GUARD 0
  185. #endif
  186. #ifndef _COMPILER_VERSION
  187. #define _COMPILER_VERSION_WORKAROUND_GUARD 1
  188. #else
  189. #define _COMPILER_VERSION_WORKAROUND_GUARD 0
  190. #endif
  191. #ifndef __clang_major__
  192. #define __clang_major___WORKAROUND_GUARD 1
  193. #else
  194. #define __clang_major___WORKAROUND_GUARD 0
  195. #endif
  196. #ifndef _RWSTD_VER
  197. #define _RWSTD_VER_WORKAROUND_GUARD 1
  198. #else
  199. #define _RWSTD_VER_WORKAROUND_GUARD 0
  200. #endif
  201. #ifndef BOOST_RWSTD_VER
  202. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
  203. #else
  204. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
  205. #endif
  206. #ifndef __GLIBCPP__
  207. #define __GLIBCPP___WORKAROUND_GUARD 1
  208. #else
  209. #define __GLIBCPP___WORKAROUND_GUARD 0
  210. #endif
  211. #ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  212. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
  213. #else
  214. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
  215. #endif
  216. #ifndef __SGI_STL_PORT
  217. #define __SGI_STL_PORT_WORKAROUND_GUARD 1
  218. #else
  219. #define __SGI_STL_PORT_WORKAROUND_GUARD 0
  220. #endif
  221. #ifndef _STLPORT_VERSION
  222. #define _STLPORT_VERSION_WORKAROUND_GUARD 1
  223. #else
  224. #define _STLPORT_VERSION_WORKAROUND_GUARD 0
  225. #endif
  226. #ifndef __LIBCOMO_VERSION__
  227. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
  228. #else
  229. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
  230. #endif
  231. #ifndef _CPPLIB_VER
  232. #define _CPPLIB_VER_WORKAROUND_GUARD 1
  233. #else
  234. #define _CPPLIB_VER_WORKAROUND_GUARD 0
  235. #endif
  236. #ifndef BOOST_INTEL_CXX_VERSION
  237. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
  238. #else
  239. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
  240. #endif
  241. #ifndef BOOST_INTEL_WIN
  242. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
  243. #else
  244. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
  245. #endif
  246. #ifndef BOOST_DINKUMWARE_STDLIB
  247. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
  248. #else
  249. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
  250. #endif
  251. #ifndef BOOST_INTEL
  252. #define BOOST_INTEL_WORKAROUND_GUARD 1
  253. #else
  254. #define BOOST_INTEL_WORKAROUND_GUARD 0
  255. #endif
  256. #ifndef BOOST_CLANG_VERSION
  257. #define BOOST_CLANG_VERSION_WORKAROUND_GUARD 1
  258. #else
  259. #define BOOST_CLANG_VERSION_WORKAROUND_GUARD 0
  260. #endif
  261. // Always define to zero, if it's used it'll be defined my MPL:
  262. #define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
  263. #define BOOST_WORKAROUND(symbol, test) \
  264. ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
  265. (symbol != 0) && (1 % (( (symbol test) ) + 1)))
  266. // ^ ^ ^ ^
  267. // The extra level of parenthesis nesting above, along with the
  268. // BOOST_OPEN_PAREN indirection below, is required to satisfy the
  269. // broken preprocessor in MWCW 8.3 and earlier.
  270. //
  271. // The basic mechanism works as follows:
  272. // (symbol test) + 1 => if (symbol test) then 2 else 1
  273. // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
  274. //
  275. // The complication with % is for cooperation with BOOST_TESTED_AT().
  276. // When "test" is BOOST_TESTED_AT(x) and
  277. // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
  278. //
  279. // symbol test => if (symbol <= x) then 1 else -1
  280. // (symbol test) + 1 => if (symbol <= x) then 2 else 0
  281. // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
  282. //
  283. #ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
  284. # define BOOST_OPEN_PAREN (
  285. # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
  286. #else
  287. # define BOOST_TESTED_AT(value) != ((value)-(value))
  288. #endif
  289. #else
  290. #define BOOST_WORKAROUND(symbol, test) 0
  291. #endif
  292. #endif // BOOST_CONFIG_WORKAROUND_HPP