workaround.hpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 _RWSTD_VER
  192. #define _RWSTD_VER_WORKAROUND_GUARD 1
  193. #else
  194. #define _RWSTD_VER_WORKAROUND_GUARD 0
  195. #endif
  196. #ifndef BOOST_RWSTD_VER
  197. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
  198. #else
  199. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
  200. #endif
  201. #ifndef __GLIBCPP__
  202. #define __GLIBCPP___WORKAROUND_GUARD 1
  203. #else
  204. #define __GLIBCPP___WORKAROUND_GUARD 0
  205. #endif
  206. #ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  207. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
  208. #else
  209. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
  210. #endif
  211. #ifndef __SGI_STL_PORT
  212. #define __SGI_STL_PORT_WORKAROUND_GUARD 1
  213. #else
  214. #define __SGI_STL_PORT_WORKAROUND_GUARD 0
  215. #endif
  216. #ifndef _STLPORT_VERSION
  217. #define _STLPORT_VERSION_WORKAROUND_GUARD 1
  218. #else
  219. #define _STLPORT_VERSION_WORKAROUND_GUARD 0
  220. #endif
  221. #ifndef __LIBCOMO_VERSION__
  222. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
  223. #else
  224. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
  225. #endif
  226. #ifndef _CPPLIB_VER
  227. #define _CPPLIB_VER_WORKAROUND_GUARD 1
  228. #else
  229. #define _CPPLIB_VER_WORKAROUND_GUARD 0
  230. #endif
  231. #ifndef BOOST_INTEL_CXX_VERSION
  232. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
  233. #else
  234. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
  235. #endif
  236. #ifndef BOOST_INTEL_WIN
  237. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
  238. #else
  239. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
  240. #endif
  241. #ifndef BOOST_DINKUMWARE_STDLIB
  242. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
  243. #else
  244. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
  245. #endif
  246. #ifndef BOOST_INTEL
  247. #define BOOST_INTEL_WORKAROUND_GUARD 1
  248. #else
  249. #define BOOST_INTEL_WORKAROUND_GUARD 0
  250. #endif
  251. // Always define to zero, if it's used it'll be defined my MPL:
  252. #define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
  253. #define BOOST_WORKAROUND(symbol, test) \
  254. ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
  255. (symbol != 0) && (1 % (( (symbol test) ) + 1)))
  256. // ^ ^ ^ ^
  257. // The extra level of parenthesis nesting above, along with the
  258. // BOOST_OPEN_PAREN indirection below, is required to satisfy the
  259. // broken preprocessor in MWCW 8.3 and earlier.
  260. //
  261. // The basic mechanism works as follows:
  262. // (symbol test) + 1 => if (symbol test) then 2 else 1
  263. // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
  264. //
  265. // The complication with % is for cooperation with BOOST_TESTED_AT().
  266. // When "test" is BOOST_TESTED_AT(x) and
  267. // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
  268. //
  269. // symbol test => if (symbol <= x) then 1 else -1
  270. // (symbol test) + 1 => if (symbol <= x) then 2 else 0
  271. // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
  272. //
  273. #ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
  274. # define BOOST_OPEN_PAREN (
  275. # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
  276. #else
  277. # define BOOST_TESTED_AT(value) != ((value)-(value))
  278. #endif
  279. #else
  280. #define BOOST_WORKAROUND(symbol, test) 0
  281. #endif
  282. #endif // BOOST_CONFIG_WORKAROUND_HPP