workaround.hpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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 _MSC_VER
  50. #define _MSC_VER_WORKAROUND_GUARD 1
  51. #else
  52. #define _MSC_VER_WORKAROUND_GUARD 0
  53. #endif
  54. #ifndef _MSC_FULL_VER
  55. #define _MSC_FULL_VER_WORKAROUND_GUARD 1
  56. #else
  57. #define _MSC_FULL_VER_WORKAROUND_GUARD 0
  58. #endif
  59. #ifndef BOOST_MSVC
  60. #define BOOST_MSVC_WORKAROUND_GUARD 1
  61. #else
  62. #define BOOST_MSVC_WORKAROUND_GUARD 0
  63. #endif
  64. #ifndef BOOST_MSVC_FULL_VER
  65. #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1
  66. #else
  67. #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0
  68. #endif
  69. #ifndef __GNUC__
  70. #define __GNUC___WORKAROUND_GUARD 1
  71. #else
  72. #define __GNUC___WORKAROUND_GUARD 0
  73. #endif
  74. #ifndef __GNUC_MINOR__
  75. #define __GNUC_MINOR___WORKAROUND_GUARD 1
  76. #else
  77. #define __GNUC_MINOR___WORKAROUND_GUARD 0
  78. #endif
  79. #ifndef __GNUC_PATCHLEVEL__
  80. #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 1
  81. #else
  82. #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 0
  83. #endif
  84. #ifndef BOOST_GCC
  85. #define BOOST_GCC_WORKAROUND_GUARD 1
  86. #define BOOST_GCC_VERSION_WORKAROUND_GUARD 1
  87. #else
  88. #define BOOST_GCC_WORKAROUND_GUARD 0
  89. #define BOOST_GCC_VERSION_WORKAROUND_GUARD 0
  90. #endif
  91. #ifndef BOOST_XLCPP_ZOS
  92. #define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 1
  93. #else
  94. #define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 0
  95. #endif
  96. #ifndef __IBMCPP__
  97. #define __IBMCPP___WORKAROUND_GUARD 1
  98. #else
  99. #define __IBMCPP___WORKAROUND_GUARD 0
  100. #endif
  101. #ifndef __SUNPRO_CC
  102. #define __SUNPRO_CC_WORKAROUND_GUARD 1
  103. #else
  104. #define __SUNPRO_CC_WORKAROUND_GUARD 0
  105. #endif
  106. #ifndef __DECCXX_VER
  107. #define __DECCXX_VER_WORKAROUND_GUARD 1
  108. #else
  109. #define __DECCXX_VER_WORKAROUND_GUARD 0
  110. #endif
  111. #ifndef __MWERKS__
  112. #define __MWERKS___WORKAROUND_GUARD 1
  113. #else
  114. #define __MWERKS___WORKAROUND_GUARD 0
  115. #endif
  116. #ifndef __EDG__
  117. #define __EDG___WORKAROUND_GUARD 1
  118. #else
  119. #define __EDG___WORKAROUND_GUARD 0
  120. #endif
  121. #ifndef __EDG_VERSION__
  122. #define __EDG_VERSION___WORKAROUND_GUARD 1
  123. #else
  124. #define __EDG_VERSION___WORKAROUND_GUARD 0
  125. #endif
  126. #ifndef __HP_aCC
  127. #define __HP_aCC_WORKAROUND_GUARD 1
  128. #else
  129. #define __HP_aCC_WORKAROUND_GUARD 0
  130. #endif
  131. #ifndef __hpxstd98
  132. #define __hpxstd98_WORKAROUND_GUARD 1
  133. #else
  134. #define __hpxstd98_WORKAROUND_GUARD 0
  135. #endif
  136. #ifndef _CRAYC
  137. #define _CRAYC_WORKAROUND_GUARD 1
  138. #else
  139. #define _CRAYC_WORKAROUND_GUARD 0
  140. #endif
  141. #ifndef __DMC__
  142. #define __DMC___WORKAROUND_GUARD 1
  143. #else
  144. #define __DMC___WORKAROUND_GUARD 0
  145. #endif
  146. #ifndef MPW_CPLUS
  147. #define MPW_CPLUS_WORKAROUND_GUARD 1
  148. #else
  149. #define MPW_CPLUS_WORKAROUND_GUARD 0
  150. #endif
  151. #ifndef __COMO__
  152. #define __COMO___WORKAROUND_GUARD 1
  153. #else
  154. #define __COMO___WORKAROUND_GUARD 0
  155. #endif
  156. #ifndef __COMO_VERSION__
  157. #define __COMO_VERSION___WORKAROUND_GUARD 1
  158. #else
  159. #define __COMO_VERSION___WORKAROUND_GUARD 0
  160. #endif
  161. #ifndef __INTEL_COMPILER
  162. #define __INTEL_COMPILER_WORKAROUND_GUARD 1
  163. #else
  164. #define __INTEL_COMPILER_WORKAROUND_GUARD 0
  165. #endif
  166. #ifndef __ICL
  167. #define __ICL_WORKAROUND_GUARD 1
  168. #else
  169. #define __ICL_WORKAROUND_GUARD 0
  170. #endif
  171. #ifndef _COMPILER_VERSION
  172. #define _COMPILER_VERSION_WORKAROUND_GUARD 1
  173. #else
  174. #define _COMPILER_VERSION_WORKAROUND_GUARD 0
  175. #endif
  176. #ifndef _RWSTD_VER
  177. #define _RWSTD_VER_WORKAROUND_GUARD 1
  178. #else
  179. #define _RWSTD_VER_WORKAROUND_GUARD 0
  180. #endif
  181. #ifndef BOOST_RWSTD_VER
  182. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
  183. #else
  184. #define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
  185. #endif
  186. #ifndef __GLIBCPP__
  187. #define __GLIBCPP___WORKAROUND_GUARD 1
  188. #else
  189. #define __GLIBCPP___WORKAROUND_GUARD 0
  190. #endif
  191. #ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  192. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
  193. #else
  194. #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
  195. #endif
  196. #ifndef __SGI_STL_PORT
  197. #define __SGI_STL_PORT_WORKAROUND_GUARD 1
  198. #else
  199. #define __SGI_STL_PORT_WORKAROUND_GUARD 0
  200. #endif
  201. #ifndef _STLPORT_VERSION
  202. #define _STLPORT_VERSION_WORKAROUND_GUARD 1
  203. #else
  204. #define _STLPORT_VERSION_WORKAROUND_GUARD 0
  205. #endif
  206. #ifndef __LIBCOMO_VERSION__
  207. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
  208. #else
  209. #define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
  210. #endif
  211. #ifndef _CPPLIB_VER
  212. #define _CPPLIB_VER_WORKAROUND_GUARD 1
  213. #else
  214. #define _CPPLIB_VER_WORKAROUND_GUARD 0
  215. #endif
  216. #ifndef BOOST_INTEL_CXX_VERSION
  217. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
  218. #else
  219. #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
  220. #endif
  221. #ifndef BOOST_INTEL_WIN
  222. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
  223. #else
  224. #define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
  225. #endif
  226. #ifndef BOOST_DINKUMWARE_STDLIB
  227. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
  228. #else
  229. #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
  230. #endif
  231. #ifndef BOOST_INTEL
  232. #define BOOST_INTEL_WORKAROUND_GUARD 1
  233. #else
  234. #define BOOST_INTEL_WORKAROUND_GUARD 0
  235. #endif
  236. // Always define to zero, if it's used it'll be defined my MPL:
  237. #define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
  238. #define BOOST_WORKAROUND(symbol, test) \
  239. ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
  240. (symbol != 0) && (1 % (( (symbol test) ) + 1)))
  241. // ^ ^ ^ ^
  242. // The extra level of parenthesis nesting above, along with the
  243. // BOOST_OPEN_PAREN indirection below, is required to satisfy the
  244. // broken preprocessor in MWCW 8.3 and earlier.
  245. //
  246. // The basic mechanism works as follows:
  247. // (symbol test) + 1 => if (symbol test) then 2 else 1
  248. // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
  249. //
  250. // The complication with % is for cooperation with BOOST_TESTED_AT().
  251. // When "test" is BOOST_TESTED_AT(x) and
  252. // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
  253. //
  254. // symbol test => if (symbol <= x) then 1 else -1
  255. // (symbol test) + 1 => if (symbol <= x) then 2 else 0
  256. // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
  257. //
  258. #ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
  259. # define BOOST_OPEN_PAREN (
  260. # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
  261. #else
  262. # define BOOST_TESTED_AT(value) != ((value)-(value))
  263. #endif
  264. #else
  265. #define BOOST_WORKAROUND(symbol, test) 0
  266. #endif
  267. #endif // BOOST_CONFIG_WORKAROUND_HPP