libstdcpp3.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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(<memory_resource>)
  115. # define BOOST_LIBSTDCXX_VERSION 90100
  116. #elif __has_include(<charconv>)
  117. # define BOOST_LIBSTDCXX_VERSION 80100
  118. #elif __has_include(<variant>)
  119. # define BOOST_LIBSTDCXX_VERSION 70100
  120. #elif __has_include(<experimental/memory_resource>)
  121. # define BOOST_LIBSTDCXX_VERSION 60100
  122. #elif __has_include(<experimental/any>)
  123. # define BOOST_LIBSTDCXX_VERSION 50100
  124. #elif __has_include(<shared_mutex>)
  125. # define BOOST_LIBSTDCXX_VERSION 40900
  126. #elif __has_include(<ext/cmath>)
  127. # define BOOST_LIBSTDCXX_VERSION 40800
  128. #elif __has_include(<scoped_allocator>)
  129. # define BOOST_LIBSTDCXX_VERSION 40700
  130. #elif __has_include(<typeindex>)
  131. # define BOOST_LIBSTDCXX_VERSION 40600
  132. #elif __has_include(<future>)
  133. # define BOOST_LIBSTDCXX_VERSION 40500
  134. #elif __has_include(<ratio>)
  135. # define BOOST_LIBSTDCXX_VERSION 40400
  136. #elif __has_include(<array>)
  137. # define BOOST_LIBSTDCXX_VERSION 40300
  138. #endif
  139. #if (BOOST_LIBSTDCXX_VERSION < 50100)
  140. // libstdc++ does not define this function as it's deprecated in C++11, but clang still looks for it,
  141. // defining it here is a terrible cludge, but should get things working:
  142. extern "C" char *gets (char *__s);
  143. #endif
  144. //
  145. // clang is unable to parse some GCC headers, add those workarounds here:
  146. //
  147. #if BOOST_LIBSTDCXX_VERSION < 50000
  148. # define BOOST_NO_CXX11_HDR_REGEX
  149. #endif
  150. //
  151. // GCC 4.7.x has no __cxa_thread_atexit which
  152. // thread_local objects require for cleanup:
  153. //
  154. #if BOOST_LIBSTDCXX_VERSION < 40800
  155. # define BOOST_NO_CXX11_THREAD_LOCAL
  156. #endif
  157. //
  158. // Early clang versions can handle <chrono>, not exactly sure which versions
  159. // but certainly up to clang-3.8 and gcc-4.6:
  160. //
  161. #if (__clang_major__ < 5)
  162. # if BOOST_LIBSTDCXX_VERSION < 40800
  163. # define BOOST_NO_CXX11_HDR_FUTURE
  164. # define BOOST_NO_CXX11_HDR_MUTEX
  165. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  166. # define BOOST_NO_CXX11_HDR_CHRONO
  167. # endif
  168. #endif
  169. //
  170. // GCC 4.8 and 9 add working versions of <atomic> and <regex> respectively.
  171. // However, we have no test for these as the headers were present but broken
  172. // in early GCC versions.
  173. //
  174. #endif
  175. #if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) && (__cplusplus >= 201103L)
  176. //
  177. // Oracle Solaris compiler uses it's own verison of libstdc++ but doesn't
  178. // set __GNUC__
  179. //
  180. #if __SUNPRO_CC >= 0x5140
  181. #define BOOST_LIBSTDCXX_VERSION 50100
  182. #else
  183. #define BOOST_LIBSTDCXX_VERSION 40800
  184. #endif
  185. #endif
  186. #if !defined(BOOST_LIBSTDCXX_VERSION)
  187. # define BOOST_LIBSTDCXX_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  188. #endif
  189. // std::auto_ptr isn't provided with _GLIBCXX_DEPRECATED=0 (GCC 4.5 and earlier)
  190. // or _GLIBCXX_USE_DEPRECATED=0 (GCC 4.6 and later).
  191. #if defined(BOOST_LIBSTDCXX11)
  192. # if BOOST_LIBSTDCXX_VERSION < 40600
  193. # if !_GLIBCXX_DEPRECATED
  194. # define BOOST_NO_AUTO_PTR
  195. # endif
  196. # elif !_GLIBCXX_USE_DEPRECATED
  197. # define BOOST_NO_AUTO_PTR
  198. # endif
  199. #endif
  200. // C++0x headers in GCC 4.3.0 and later
  201. //
  202. #if (BOOST_LIBSTDCXX_VERSION < 40300) || !defined(BOOST_LIBSTDCXX11)
  203. # define BOOST_NO_CXX11_HDR_ARRAY
  204. # define BOOST_NO_CXX11_HDR_TUPLE
  205. # define BOOST_NO_CXX11_HDR_UNORDERED_MAP
  206. # define BOOST_NO_CXX11_HDR_UNORDERED_SET
  207. # define BOOST_NO_CXX11_HDR_FUNCTIONAL
  208. #endif
  209. // C++0x headers in GCC 4.4.0 and later
  210. //
  211. #if (BOOST_LIBSTDCXX_VERSION < 40400) || !defined(BOOST_LIBSTDCXX11)
  212. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  213. # define BOOST_NO_CXX11_HDR_FORWARD_LIST
  214. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  215. # define BOOST_NO_CXX11_HDR_MUTEX
  216. # define BOOST_NO_CXX11_HDR_RATIO
  217. # define BOOST_NO_CXX11_HDR_SYSTEM_ERROR
  218. # define BOOST_NO_CXX11_SMART_PTR
  219. # define BOOST_NO_CXX11_HDR_EXCEPTION
  220. #else
  221. # define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
  222. # define BOOST_HAS_TR1_COMPLEX_OVERLOADS
  223. #endif
  224. // C++0x features in GCC 4.5.0 and later
  225. //
  226. #if (BOOST_LIBSTDCXX_VERSION < 40500) || !defined(BOOST_LIBSTDCXX11)
  227. # define BOOST_NO_CXX11_NUMERIC_LIMITS
  228. # define BOOST_NO_CXX11_HDR_FUTURE
  229. # define BOOST_NO_CXX11_HDR_RANDOM
  230. #endif
  231. // C++0x features in GCC 4.6.0 and later
  232. //
  233. #if (BOOST_LIBSTDCXX_VERSION < 40600) || !defined(BOOST_LIBSTDCXX11)
  234. # define BOOST_NO_CXX11_HDR_TYPEINDEX
  235. # define BOOST_NO_CXX11_ADDRESSOF
  236. # define BOOST_NO_CXX17_ITERATOR_TRAITS
  237. #endif
  238. // C++0x features in GCC 4.7.0 and later
  239. //
  240. #if (BOOST_LIBSTDCXX_VERSION < 40700) || !defined(BOOST_LIBSTDCXX11)
  241. // Note that although <chrono> existed prior to 4.7, "steady_clock" is spelled "monotonic_clock"
  242. // so 4.7.0 is the first truly conforming one.
  243. # define BOOST_NO_CXX11_HDR_CHRONO
  244. # define BOOST_NO_CXX11_ALLOCATOR
  245. # define BOOST_NO_CXX11_POINTER_TRAITS
  246. #endif
  247. // C++0x features in GCC 4.8.0 and later
  248. //
  249. #if (BOOST_LIBSTDCXX_VERSION < 40800) || !defined(BOOST_LIBSTDCXX11)
  250. // Note that although <atomic> existed prior to gcc 4.8 it was largely unimplemented for many types:
  251. # define BOOST_NO_CXX11_HDR_ATOMIC
  252. # define BOOST_NO_CXX11_HDR_THREAD
  253. #endif
  254. // C++0x features in GCC 4.9.0 and later
  255. //
  256. #if (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  257. // Although <regex> is present and compilable against, the actual implementation is not functional
  258. // even for the simplest patterns such as "\d" or "[0-9]". This is the case at least in gcc up to 4.8, inclusively.
  259. # define BOOST_NO_CXX11_HDR_REGEX
  260. #endif
  261. #if (BOOST_LIBSTDCXX_VERSION < 40900) || (__cplusplus <= 201103)
  262. # define BOOST_NO_CXX14_STD_EXCHANGE
  263. #endif
  264. #if defined(__clang_major__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 7)))
  265. // As of clang-3.6, libstdc++ header <atomic> throws up errors with clang:
  266. # define BOOST_NO_CXX11_HDR_ATOMIC
  267. #endif
  268. //
  269. // C++0x features in GCC 5.1 and later
  270. //
  271. #if (BOOST_LIBSTDCXX_VERSION < 50100) || !defined(BOOST_LIBSTDCXX11)
  272. # define BOOST_NO_CXX11_HDR_TYPE_TRAITS
  273. # define BOOST_NO_CXX11_HDR_CODECVT
  274. # define BOOST_NO_CXX11_ATOMIC_SMART_PTR
  275. # define BOOST_NO_CXX11_STD_ALIGN
  276. #endif
  277. //
  278. // C++17 features in GCC 7.1 and later
  279. //
  280. #if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
  281. # define BOOST_NO_CXX17_STD_INVOKE
  282. # define BOOST_NO_CXX17_STD_APPLY
  283. # define BOOST_NO_CXX17_HDR_OPTIONAL
  284. # define BOOST_NO_CXX17_HDR_STRING_VIEW
  285. # define BOOST_NO_CXX17_HDR_VARIANT
  286. #endif
  287. #if defined(__has_include)
  288. #if !__has_include(<shared_mutex>)
  289. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  290. #elif __cplusplus <= 201103
  291. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  292. #endif
  293. #elif __cplusplus < 201402 || (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  294. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  295. #endif
  296. //
  297. // Headers not present on Solaris with the Oracle compiler:
  298. #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
  299. #define BOOST_NO_CXX11_HDR_FUTURE
  300. #define BOOST_NO_CXX11_HDR_FORWARD_LIST
  301. #define BOOST_NO_CXX11_HDR_ATOMIC
  302. // shared_ptr is present, but is not convertible to bool
  303. // which causes all kinds of problems especially in Boost.Thread
  304. // but probably elsewhere as well.
  305. #define BOOST_NO_CXX11_SMART_PTR
  306. #endif
  307. #if (!defined(_GLIBCXX_HAS_GTHREADS) || !defined(_GLIBCXX_USE_C99_STDINT_TR1))
  308. // Headers not always available:
  309. # ifndef BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  310. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  311. # endif
  312. # ifndef BOOST_NO_CXX11_HDR_MUTEX
  313. # define BOOST_NO_CXX11_HDR_MUTEX
  314. # endif
  315. # ifndef BOOST_NO_CXX11_HDR_THREAD
  316. # define BOOST_NO_CXX11_HDR_THREAD
  317. # endif
  318. # ifndef BOOST_NO_CXX14_HDR_SHARED_MUTEX
  319. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  320. # endif
  321. #endif
  322. #if (!defined(_GTHREAD_USE_MUTEX_TIMEDLOCK) || (_GTHREAD_USE_MUTEX_TIMEDLOCK == 0)) && !defined(BOOST_NO_CXX11_HDR_MUTEX)
  323. // Timed mutexes are not always available:
  324. # define BOOST_NO_CXX11_HDR_MUTEX
  325. #endif
  326. // --- end ---