libstdcpp3.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. // (C) Copyright John Maddock 2001.
  2. // (C) Copyright Jens Maurer 2001.
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. // See http://www.boost.org for most recent version.
  7. // config for libstdc++ v3
  8. // not much to go in here:
  9. #define BOOST_GNU_STDLIB 1
  10. #ifdef __GLIBCXX__
  11. #define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCXX__)
  12. #else
  13. #define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCPP__)
  14. #endif
  15. #if !defined(_GLIBCPP_USE_WCHAR_T) && !defined(_GLIBCXX_USE_WCHAR_T)
  16. # define BOOST_NO_CWCHAR
  17. # define BOOST_NO_CWCTYPE
  18. # define BOOST_NO_STD_WSTRING
  19. # define BOOST_NO_STD_WSTREAMBUF
  20. #endif
  21. #if defined(__osf__) && !defined(_REENTRANT) \
  22. && ( defined(_GLIBCXX_HAVE_GTHR_DEFAULT) || defined(_GLIBCPP_HAVE_GTHR_DEFAULT) )
  23. // GCC 3 on Tru64 forces the definition of _REENTRANT when any std lib header
  24. // file is included, therefore for consistency we define it here as well.
  25. # define _REENTRANT
  26. #endif
  27. #ifdef __GLIBCXX__ // gcc 3.4 and greater:
  28. # if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
  29. || defined(_GLIBCXX__PTHREADS) \
  30. || defined(_GLIBCXX_HAS_GTHREADS) \
  31. || defined(_WIN32) \
  32. || defined(_AIX) \
  33. || defined(__HAIKU__)
  34. //
  35. // If the std lib has thread support turned on, then turn it on in Boost
  36. // as well. We do this because some gcc-3.4 std lib headers define _REENTANT
  37. // while others do not...
  38. //
  39. # define BOOST_HAS_THREADS
  40. # else
  41. # define BOOST_DISABLE_THREADS
  42. # endif
  43. #elif defined(__GLIBCPP__) \
  44. && !defined(_GLIBCPP_HAVE_GTHR_DEFAULT) \
  45. && !defined(_GLIBCPP__PTHREADS)
  46. // disable thread support if the std lib was built single threaded:
  47. # define BOOST_DISABLE_THREADS
  48. #endif
  49. #if (defined(linux) || defined(__linux) || defined(__linux__)) && defined(__arm__) && defined(_GLIBCPP_HAVE_GTHR_DEFAULT)
  50. // linux on arm apparently doesn't define _REENTRANT
  51. // so just turn on threading support whenever the std lib is thread safe:
  52. # define BOOST_HAS_THREADS
  53. #endif
  54. #if !defined(_GLIBCPP_USE_LONG_LONG) \
  55. && !defined(_GLIBCXX_USE_LONG_LONG)\
  56. && defined(BOOST_HAS_LONG_LONG)
  57. // May have been set by compiler/*.hpp, but "long long" without library
  58. // support is useless.
  59. # undef BOOST_HAS_LONG_LONG
  60. #endif
  61. // Apple doesn't seem to reliably defined a *unix* macro
  62. #if !defined(CYGWIN) && ( defined(__unix__) \
  63. || defined(__unix) \
  64. || defined(unix) \
  65. || defined(__APPLE__) \
  66. || defined(__APPLE) \
  67. || defined(APPLE))
  68. # include <unistd.h>
  69. #endif
  70. #ifndef __VXWORKS__ // VxWorks uses Dinkum, not GNU STL with GCC
  71. #if defined(__GLIBCXX__) || (defined(__GLIBCPP__) && __GLIBCPP__>=20020514) // GCC >= 3.1.0
  72. # define BOOST_STD_EXTENSION_NAMESPACE __gnu_cxx
  73. # define BOOST_HAS_SLIST
  74. # define BOOST_HAS_HASH
  75. # define BOOST_SLIST_HEADER <ext/slist>
  76. # if !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
  77. # define BOOST_HASH_SET_HEADER <ext/hash_set>
  78. # define BOOST_HASH_MAP_HEADER <ext/hash_map>
  79. # else
  80. # define BOOST_HASH_SET_HEADER <backward/hash_set>
  81. # define BOOST_HASH_MAP_HEADER <backward/hash_map>
  82. # endif
  83. #endif
  84. #endif
  85. //
  86. // Decide whether we have C++11 support turned on:
  87. //
  88. #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103)
  89. # define BOOST_LIBSTDCXX11
  90. #endif
  91. //
  92. // Decide which version of libstdc++ we have, normally
  93. // libstdc++ C++0x support is detected via __GNUC__, __GNUC_MINOR__, and possibly
  94. // __GNUC_PATCHLEVEL__ at the suggestion of Jonathan Wakely, one of the libstdc++
  95. // developers. He also commented:
  96. //
  97. // "I'm not sure how useful __GLIBCXX__ is for your purposes, for instance in
  98. // GCC 4.2.4 it is set to 20080519 but in GCC 4.3.0 it is set to 20080305.
  99. // Although 4.3.0 was released earlier than 4.2.4, it has better C++0x support
  100. // than any release in the 4.2 series."
  101. //
  102. // Another resource for understanding libstdc++ features is:
  103. // http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#manual.intro.status.standard.200x
  104. //
  105. // However, using the GCC version number fails when the compiler is clang since this
  106. // only ever claims to emulate GCC-4.2, see https://svn.boost.org/trac/boost/ticket/7473
  107. // for a long discussion on this issue. What we can do though is use clang's __has_include
  108. // to detect the presence of a C++11 header that was introduced with a specific GCC release.
  109. // We still have to be careful though as many such headers were buggy and/or incomplete when
  110. // first introduced, so we only check for headers that were fully featured from day 1, and then
  111. // use that to infer the underlying GCC version:
  112. //
  113. #ifdef __clang__
  114. #if __has_include(<experimental/memory_resource>)
  115. # define BOOST_LIBSTDCXX_VERSION 60100
  116. #elif __has_include(<experimental/any>)
  117. # define BOOST_LIBSTDCXX_VERSION 50100
  118. #elif __has_include(<shared_mutex>)
  119. # define BOOST_LIBSTDCXX_VERSION 40900
  120. #elif __has_include(<ext/cmath>)
  121. # define BOOST_LIBSTDCXX_VERSION 40800
  122. #elif __has_include(<scoped_allocator>)
  123. # define BOOST_LIBSTDCXX_VERSION 40700
  124. #elif __has_include(<typeindex>)
  125. # define BOOST_LIBSTDCXX_VERSION 40600
  126. #elif __has_include(<future>)
  127. # define BOOST_LIBSTDCXX_VERSION 40500
  128. #elif __has_include(<ratio>)
  129. # define BOOST_LIBSTDCXX_VERSION 40400
  130. #elif __has_include(<array>)
  131. # define BOOST_LIBSTDCXX_VERSION 40300
  132. #endif
  133. #if (BOOST_LIBSTDCXX_VERSION < 50100)
  134. // libstdc++ does not define this function as it's deprecated in C++11, but clang still looks for it,
  135. // defining it here is a terrible cludge, but should get things working:
  136. extern "C" char *gets (char *__s);
  137. #endif
  138. //
  139. // clang is unable to parse some GCC headers, add those workarounds here:
  140. //
  141. #if BOOST_LIBSTDCXX_VERSION < 50000
  142. # define BOOST_NO_CXX11_HDR_REGEX
  143. #endif
  144. //
  145. // GCC 4.7.x has no __cxa_thread_atexit which
  146. // thread_local objects require for cleanup:
  147. //
  148. #if BOOST_LIBSTDCXX_VERSION < 40800
  149. # define BOOST_NO_CXX11_THREAD_LOCAL
  150. #endif
  151. //
  152. // Early clang versions can handle <chrono>, not exactly sure which versions
  153. // but certainly up to clang-3.8 and gcc-4.6:
  154. //
  155. #if (__clang_major__ < 5)
  156. # if BOOST_LIBSTDCXX_VERSION < 40800
  157. # define BOOST_NO_CXX11_HDR_FUTURE
  158. # define BOOST_NO_CXX11_HDR_MUTEX
  159. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  160. # define BOOST_NO_CXX11_HDR_CHRONO
  161. # endif
  162. #endif
  163. //
  164. // GCC 4.8 and 9 add working versions of <atomic> and <regex> respectively.
  165. // However, we have no test for these as the headers were present but broken
  166. // in early GCC versions.
  167. //
  168. #endif
  169. #if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) && (__cplusplus >= 201103L)
  170. //
  171. // Oracle Solaris compiler uses it's own verison of libstdc++ but doesn't
  172. // set __GNUC__
  173. //
  174. #if __SUNPRO_CC >= 0x5140
  175. #define BOOST_LIBSTDCXX_VERSION 50100
  176. #else
  177. #define BOOST_LIBSTDCXX_VERSION 40800
  178. #endif
  179. #endif
  180. #if !defined(BOOST_LIBSTDCXX_VERSION)
  181. # define BOOST_LIBSTDCXX_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  182. #endif
  183. // std::auto_ptr isn't provided with _GLIBCXX_DEPRECATED=0 (GCC 4.5 and earlier)
  184. // or _GLIBCXX_USE_DEPRECATED=0 (GCC 4.6 and later).
  185. #if defined(BOOST_LIBSTDCXX11)
  186. # if BOOST_LIBSTDCXX_VERSION < 40600
  187. # if !_GLIBCXX_DEPRECATED
  188. # define BOOST_NO_AUTO_PTR
  189. # endif
  190. # elif !_GLIBCXX_USE_DEPRECATED
  191. # define BOOST_NO_AUTO_PTR
  192. # endif
  193. #endif
  194. // C++0x headers in GCC 4.3.0 and later
  195. //
  196. #if (BOOST_LIBSTDCXX_VERSION < 40300) || !defined(BOOST_LIBSTDCXX11)
  197. # define BOOST_NO_CXX11_HDR_ARRAY
  198. # define BOOST_NO_CXX11_HDR_TUPLE
  199. # define BOOST_NO_CXX11_HDR_UNORDERED_MAP
  200. # define BOOST_NO_CXX11_HDR_UNORDERED_SET
  201. # define BOOST_NO_CXX11_HDR_FUNCTIONAL
  202. #endif
  203. // C++0x headers in GCC 4.4.0 and later
  204. //
  205. #if (BOOST_LIBSTDCXX_VERSION < 40400) || !defined(BOOST_LIBSTDCXX11)
  206. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  207. # define BOOST_NO_CXX11_HDR_FORWARD_LIST
  208. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  209. # define BOOST_NO_CXX11_HDR_MUTEX
  210. # define BOOST_NO_CXX11_HDR_RATIO
  211. # define BOOST_NO_CXX11_HDR_SYSTEM_ERROR
  212. # define BOOST_NO_CXX11_SMART_PTR
  213. #else
  214. # define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
  215. # define BOOST_HAS_TR1_COMPLEX_OVERLOADS
  216. #endif
  217. // C++0x features in GCC 4.5.0 and later
  218. //
  219. #if (BOOST_LIBSTDCXX_VERSION < 40500) || !defined(BOOST_LIBSTDCXX11)
  220. # define BOOST_NO_CXX11_NUMERIC_LIMITS
  221. # define BOOST_NO_CXX11_HDR_FUTURE
  222. # define BOOST_NO_CXX11_HDR_RANDOM
  223. #endif
  224. // C++0x features in GCC 4.6.0 and later
  225. //
  226. #if (BOOST_LIBSTDCXX_VERSION < 40600) || !defined(BOOST_LIBSTDCXX11)
  227. # define BOOST_NO_CXX11_HDR_TYPEINDEX
  228. # define BOOST_NO_CXX11_ADDRESSOF
  229. # define BOOST_NO_CXX17_ITERATOR_TRAITS
  230. #endif
  231. // C++0x features in GCC 4.7.0 and later
  232. //
  233. #if (BOOST_LIBSTDCXX_VERSION < 40700) || !defined(BOOST_LIBSTDCXX11)
  234. // Note that although <chrono> existed prior to 4.7, "steady_clock" is spelled "monotonic_clock"
  235. // so 4.7.0 is the first truly conforming one.
  236. # define BOOST_NO_CXX11_HDR_CHRONO
  237. # define BOOST_NO_CXX11_ALLOCATOR
  238. # define BOOST_NO_CXX11_POINTER_TRAITS
  239. #endif
  240. // C++0x features in GCC 4.8.0 and later
  241. //
  242. #if (BOOST_LIBSTDCXX_VERSION < 40800) || !defined(BOOST_LIBSTDCXX11)
  243. // Note that although <atomic> existed prior to gcc 4.8 it was largely unimplemented for many types:
  244. # define BOOST_NO_CXX11_HDR_ATOMIC
  245. # define BOOST_NO_CXX11_HDR_THREAD
  246. #endif
  247. // C++0x features in GCC 4.9.0 and later
  248. //
  249. #if (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  250. // Although <regex> is present and compilable against, the actual implementation is not functional
  251. // even for the simplest patterns such as "\d" or "[0-9]". This is the case at least in gcc up to 4.8, inclusively.
  252. # define BOOST_NO_CXX11_HDR_REGEX
  253. #endif
  254. #if (BOOST_LIBSTDCXX_VERSION < 40900) || (__cplusplus <= 201103)
  255. # define BOOST_NO_CXX14_STD_EXCHANGE
  256. #endif
  257. #if defined(__clang_major__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 7)))
  258. // As of clang-3.6, libstdc++ header <atomic> throws up errors with clang:
  259. # define BOOST_NO_CXX11_HDR_ATOMIC
  260. #endif
  261. //
  262. // C++0x features in GCC 5.1 and later
  263. //
  264. #if (BOOST_LIBSTDCXX_VERSION < 50100) || !defined(BOOST_LIBSTDCXX11)
  265. # define BOOST_NO_CXX11_HDR_TYPE_TRAITS
  266. # define BOOST_NO_CXX11_HDR_CODECVT
  267. # define BOOST_NO_CXX11_ATOMIC_SMART_PTR
  268. # define BOOST_NO_CXX11_STD_ALIGN
  269. #endif
  270. //
  271. // C++17 features in GCC 7.1 and later
  272. //
  273. #if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
  274. # define BOOST_NO_CXX17_STD_INVOKE
  275. # define BOOST_NO_CXX17_STD_APPLY
  276. # define BOOST_NO_CXX17_HDR_OPTIONAL
  277. # define BOOST_NO_CXX17_HDR_STRING_VIEW
  278. # define BOOST_NO_CXX17_HDR_VARIANT
  279. #endif
  280. #if defined(__has_include)
  281. #if !__has_include(<shared_mutex>)
  282. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  283. #elif __cplusplus <= 201103
  284. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  285. #endif
  286. #elif __cplusplus < 201402 || (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  287. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  288. #endif
  289. //
  290. // Headers not present on Solaris with the Oracle compiler:
  291. #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
  292. #define BOOST_NO_CXX11_HDR_FUTURE
  293. #define BOOST_NO_CXX11_HDR_FORWARD_LIST
  294. #define BOOST_NO_CXX11_HDR_ATOMIC
  295. // shared_ptr is present, but is not convertible to bool
  296. // which causes all kinds of problems especially in Boost.Thread
  297. // but probably elsewhere as well.
  298. #define BOOST_NO_CXX11_SMART_PTR
  299. #endif
  300. #if (!defined(_GLIBCXX_HAS_GTHREADS) || !defined(_GLIBCXX_USE_C99_STDINT_TR1))
  301. // Headers not always available:
  302. # ifndef BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  303. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  304. # endif
  305. # ifndef BOOST_NO_CXX11_HDR_MUTEX
  306. # define BOOST_NO_CXX11_HDR_MUTEX
  307. # endif
  308. # ifndef BOOST_NO_CXX11_HDR_THREAD
  309. # define BOOST_NO_CXX11_HDR_THREAD
  310. # endif
  311. # ifndef BOOST_NO_CXX14_HDR_SHARED_MUTEX
  312. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  313. # endif
  314. #endif
  315. #if (!defined(_GTHREAD_USE_MUTEX_TIMEDLOCK) || (_GTHREAD_USE_MUTEX_TIMEDLOCK == 0)) && !defined(BOOST_NO_CXX11_HDR_MUTEX)
  316. // Timed mutexes are not always available:
  317. # define BOOST_NO_CXX11_HDR_MUTEX
  318. #endif
  319. // --- end ---