gcc.hpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. // (C) Copyright John Maddock 2001 - 2003.
  2. // (C) Copyright Darin Adler 2001 - 2002.
  3. // (C) Copyright Jens Maurer 2001 - 2002.
  4. // (C) Copyright Beman Dawes 2001 - 2003.
  5. // (C) Copyright Douglas Gregor 2002.
  6. // (C) Copyright David Abrahams 2002 - 2003.
  7. // (C) Copyright Synge Todo 2003.
  8. // Use, modification and distribution are subject to the
  9. // Boost Software License, Version 1.0. (See accompanying file
  10. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  11. // See http://www.boost.org for most recent version.
  12. // GNU C++ compiler setup.
  13. //
  14. // Define BOOST_GCC so we know this is "real" GCC and not some pretender:
  15. //
  16. #define BOOST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  17. #if !defined(__CUDACC__)
  18. #define BOOST_GCC BOOST_GCC_VERSION
  19. #endif
  20. #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
  21. # define BOOST_GCC_CXX11
  22. #endif
  23. #if __GNUC__ == 3
  24. # if defined (__PATHSCALE__)
  25. # define BOOST_NO_TWO_PHASE_NAME_LOOKUP
  26. # define BOOST_NO_IS_ABSTRACT
  27. # endif
  28. # if __GNUC_MINOR__ < 4
  29. # define BOOST_NO_IS_ABSTRACT
  30. # endif
  31. # define BOOST_NO_CXX11_EXTERN_TEMPLATE
  32. #endif
  33. #if __GNUC__ < 4
  34. //
  35. // All problems to gcc-3.x and earlier here:
  36. //
  37. #define BOOST_NO_TWO_PHASE_NAME_LOOKUP
  38. # ifdef __OPEN64__
  39. # define BOOST_NO_IS_ABSTRACT
  40. # endif
  41. #endif
  42. // GCC prior to 3.4 had #pragma once too but it didn't work well with filesystem links
  43. #if BOOST_GCC_VERSION >= 30400
  44. #define BOOST_HAS_PRAGMA_ONCE
  45. #endif
  46. #if BOOST_GCC_VERSION < 40400
  47. // Previous versions of GCC did not completely implement value-initialization:
  48. // GCC Bug 30111, "Value-initialization of POD base class doesn't initialize
  49. // members", reported by Jonathan Wakely in 2006,
  50. // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 (fixed for GCC 4.4)
  51. // GCC Bug 33916, "Default constructor fails to initialize array members",
  52. // reported by Michael Elizabeth Chastain in 2007,
  53. // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 (fixed for GCC 4.2.4)
  54. // See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues
  55. #define BOOST_NO_COMPLETE_VALUE_INITIALIZATION
  56. #endif
  57. #if !defined(__EXCEPTIONS) && !defined(BOOST_NO_EXCEPTIONS)
  58. # define BOOST_NO_EXCEPTIONS
  59. #endif
  60. //
  61. // Threading support: Turn this on unconditionally here (except for
  62. // those platforms where we can know for sure). It will get turned off again
  63. // later if no threading API is detected.
  64. //
  65. #if !defined(__MINGW32__) && !defined(linux) && !defined(__linux) && !defined(__linux__)
  66. # define BOOST_HAS_THREADS
  67. #endif
  68. //
  69. // gcc has "long long"
  70. // Except on Darwin with standard compliance enabled (-pedantic)
  71. // Apple gcc helpfully defines this macro we can query
  72. //
  73. #if !defined(__DARWIN_NO_LONG_LONG)
  74. # define BOOST_HAS_LONG_LONG
  75. #endif
  76. //
  77. // gcc implements the named return value optimization since version 3.1
  78. //
  79. #define BOOST_HAS_NRVO
  80. // Branch prediction hints
  81. #define BOOST_LIKELY(x) __builtin_expect(x, 1)
  82. #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
  83. //
  84. // Dynamic shared object (DSO) and dynamic-link library (DLL) support
  85. //
  86. #if __GNUC__ >= 4
  87. # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
  88. // All Win32 development environments, including 64-bit Windows and MinGW, define
  89. // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment,
  90. // so does not define _WIN32 or its variants, but still supports dllexport/dllimport.
  91. # define BOOST_HAS_DECLSPEC
  92. # define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__))
  93. # define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__))
  94. # else
  95. # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
  96. # define BOOST_SYMBOL_IMPORT
  97. # endif
  98. # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
  99. #else
  100. // config/platform/win32.hpp will define BOOST_SYMBOL_EXPORT, etc., unless already defined
  101. # define BOOST_SYMBOL_EXPORT
  102. #endif
  103. //
  104. // RTTI and typeinfo detection is possible post gcc-4.3:
  105. //
  106. #if BOOST_GCC_VERSION > 40300
  107. # ifndef __GXX_RTTI
  108. # ifndef BOOST_NO_TYPEID
  109. # define BOOST_NO_TYPEID
  110. # endif
  111. # ifndef BOOST_NO_RTTI
  112. # define BOOST_NO_RTTI
  113. # endif
  114. # endif
  115. #endif
  116. //
  117. // Recent GCC versions have __int128 when in 64-bit mode.
  118. //
  119. // We disable this if the compiler is really nvcc with C++03 as it
  120. // doesn't actually support __int128 as of CUDA_VERSION=7500
  121. // even though it defines __SIZEOF_INT128__.
  122. // See https://svn.boost.org/trac/boost/ticket/8048
  123. // https://svn.boost.org/trac/boost/ticket/11852
  124. // Only re-enable this for nvcc if you're absolutely sure
  125. // of the circumstances under which it's supported:
  126. //
  127. #if defined(__CUDACC__)
  128. # if defined(BOOST_GCC_CXX11)
  129. # define BOOST_NVCC_CXX11
  130. # else
  131. # define BOOST_NVCC_CXX03
  132. # endif
  133. #endif
  134. #if defined(__SIZEOF_INT128__) && !defined(BOOST_NVCC_CXX03)
  135. # define BOOST_HAS_INT128
  136. #endif
  137. //
  138. // Recent GCC versions have a __float128 native type, we need to
  139. // include a std lib header to detect this - not ideal, but we'll
  140. // be including <cstddef> later anyway when we select the std lib.
  141. //
  142. // Nevertheless, as of CUDA 7.5, using __float128 with the host
  143. // compiler in pre-C++11 mode is still not supported.
  144. // See https://svn.boost.org/trac/boost/ticket/11852
  145. //
  146. #ifdef __cplusplus
  147. #include <cstddef>
  148. #else
  149. #include <stddef.h>
  150. #endif
  151. #if defined(_GLIBCXX_USE_FLOAT128) && !defined(__STRICT_ANSI__) && !defined(BOOST_NVCC_CXX03)
  152. # define BOOST_HAS_FLOAT128
  153. #endif
  154. // C++0x features in 4.3.n and later
  155. //
  156. #if (BOOST_GCC_VERSION >= 40300) && defined(BOOST_GCC_CXX11)
  157. // C++0x features are only enabled when -std=c++0x or -std=gnu++0x are
  158. // passed on the command line, which in turn defines
  159. // __GXX_EXPERIMENTAL_CXX0X__.
  160. # define BOOST_HAS_DECLTYPE
  161. # define BOOST_HAS_RVALUE_REFS
  162. # define BOOST_HAS_STATIC_ASSERT
  163. # define BOOST_HAS_VARIADIC_TMPL
  164. #else
  165. # define BOOST_NO_CXX11_DECLTYPE
  166. # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
  167. # define BOOST_NO_CXX11_RVALUE_REFERENCES
  168. # define BOOST_NO_CXX11_STATIC_ASSERT
  169. #endif
  170. // C++0x features in 4.4.n and later
  171. //
  172. #if (BOOST_GCC_VERSION < 40400) || !defined(BOOST_GCC_CXX11)
  173. # define BOOST_NO_CXX11_AUTO_DECLARATIONS
  174. # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
  175. # define BOOST_NO_CXX11_CHAR16_T
  176. # define BOOST_NO_CXX11_CHAR32_T
  177. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  178. # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
  179. # define BOOST_NO_CXX11_DELETED_FUNCTIONS
  180. # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
  181. # define BOOST_NO_CXX11_INLINE_NAMESPACES
  182. # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
  183. #endif
  184. #if BOOST_GCC_VERSION < 40500
  185. # define BOOST_NO_SFINAE_EXPR
  186. #endif
  187. // GCC 4.5 forbids declaration of defaulted functions in private or protected sections
  188. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 5) || !defined(BOOST_GCC_CXX11)
  189. # define BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS
  190. #endif
  191. // C++0x features in 4.5.0 and later
  192. //
  193. #if (BOOST_GCC_VERSION < 40500) || !defined(BOOST_GCC_CXX11)
  194. # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
  195. # define BOOST_NO_CXX11_LAMBDAS
  196. # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
  197. # define BOOST_NO_CXX11_RAW_LITERALS
  198. # define BOOST_NO_CXX11_UNICODE_LITERALS
  199. #endif
  200. // C++0x features in 4.5.1 and later
  201. //
  202. #if (BOOST_GCC_VERSION < 40501) || !defined(BOOST_GCC_CXX11)
  203. // scoped enums have a serious bug in 4.4.0, so define BOOST_NO_CXX11_SCOPED_ENUMS before 4.5.1
  204. // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38064
  205. # define BOOST_NO_CXX11_SCOPED_ENUMS
  206. #endif
  207. // C++0x features in 4.6.n and later
  208. //
  209. #if (BOOST_GCC_VERSION < 40600) || !defined(BOOST_GCC_CXX11)
  210. #define BOOST_NO_CXX11_DEFAULTED_MOVES
  211. #define BOOST_NO_CXX11_NOEXCEPT
  212. #define BOOST_NO_CXX11_NULLPTR
  213. #define BOOST_NO_CXX11_RANGE_BASED_FOR
  214. #define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
  215. #endif
  216. // C++0x features in 4.7.n and later
  217. //
  218. #if (BOOST_GCC_VERSION < 40700) || !defined(BOOST_GCC_CXX11)
  219. // Note that while constexpr is partly supported in gcc-4.6 it's a
  220. // pre-std version with several bugs:
  221. # define BOOST_NO_CXX11_CONSTEXPR
  222. # define BOOST_NO_CXX11_FINAL
  223. # define BOOST_NO_CXX11_TEMPLATE_ALIASES
  224. # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
  225. # define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS
  226. #endif
  227. // C++0x features in 4.8.n and later
  228. //
  229. #if (BOOST_GCC_VERSION < 40800) || !defined(BOOST_GCC_CXX11)
  230. # define BOOST_NO_CXX11_ALIGNAS
  231. # define BOOST_NO_CXX11_THREAD_LOCAL
  232. # define BOOST_NO_CXX11_SFINAE_EXPR
  233. #endif
  234. // C++0x features in 4.8.1 and later
  235. //
  236. #if (BOOST_GCC_VERSION < 40801) || !defined(BOOST_GCC_CXX11)
  237. # define BOOST_NO_CXX11_DECLTYPE_N3276
  238. # define BOOST_NO_CXX11_REF_QUALIFIERS
  239. # define BOOST_NO_CXX14_BINARY_LITERALS
  240. #endif
  241. // C++14 features in 4.9.0 and later
  242. //
  243. #if (BOOST_GCC_VERSION < 40900) || (__cplusplus < 201300)
  244. # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
  245. # define BOOST_NO_CXX14_GENERIC_LAMBDAS
  246. # define BOOST_NO_CXX14_DIGIT_SEPARATORS
  247. # define BOOST_NO_CXX14_DECLTYPE_AUTO
  248. # if !((BOOST_GCC_VERSION >= 40801) && (BOOST_GCC_VERSION < 40900) && defined(BOOST_GCC_CXX11))
  249. # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
  250. # endif
  251. #endif
  252. // C++ 14:
  253. #if !defined(__cpp_aggregate_nsdmi) || (__cpp_aggregate_nsdmi < 201304)
  254. # define BOOST_NO_CXX14_AGGREGATE_NSDMI
  255. #endif
  256. #if !defined(__cpp_constexpr) || (__cpp_constexpr < 201304)
  257. # define BOOST_NO_CXX14_CONSTEXPR
  258. #endif
  259. #if (BOOST_GCC_VERSION < 50200) || !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304)
  260. # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
  261. #endif
  262. // C++17
  263. #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606)
  264. # define BOOST_NO_CXX17_STRUCTURED_BINDINGS
  265. #endif
  266. #if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606)
  267. # define BOOST_NO_CXX17_INLINE_VARIABLES
  268. #endif
  269. #if !defined(__cpp_fold_expressions) || (__cpp_fold_expressions < 201603)
  270. # define BOOST_NO_CXX17_FOLD_EXPRESSIONS
  271. #endif
  272. #if !defined(__cpp_if_constexpr) || (__cpp_if_constexpr < 201606)
  273. # define BOOST_NO_CXX17_IF_CONSTEXPR
  274. #endif
  275. #if __GNUC__ >= 7
  276. # define BOOST_FALLTHROUGH __attribute__((fallthrough))
  277. #endif
  278. #if defined(__MINGW32__) && !defined(__MINGW64__)
  279. // Currently (March 2019) thread_local is broken on mingw for all current 32bit compiler releases, see
  280. // https://sourceforge.net/p/mingw-w64/bugs/527/
  281. // Not setting this causes program termination on thread exit.
  282. #define BOOST_NO_CXX11_THREAD_LOCAL
  283. #endif
  284. //
  285. // Unused attribute:
  286. #if __GNUC__ >= 4
  287. # define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
  288. #endif
  289. // Type aliasing hint. Supported since gcc 3.3.
  290. #define BOOST_MAY_ALIAS __attribute__((__may_alias__))
  291. //
  292. // __builtin_unreachable:
  293. #if BOOST_GCC_VERSION >= 40500
  294. #define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable();
  295. #endif
  296. #ifndef BOOST_COMPILER
  297. # define BOOST_COMPILER "GNU C++ version " __VERSION__
  298. #endif
  299. // ConceptGCC compiler:
  300. // http://www.generic-programming.org/software/ConceptGCC/
  301. #ifdef __GXX_CONCEPTS__
  302. # define BOOST_HAS_CONCEPTS
  303. # define BOOST_COMPILER "ConceptGCC version " __VERSION__
  304. #endif
  305. // versions check:
  306. // we don't know gcc prior to version 3.30:
  307. #if (BOOST_GCC_VERSION< 30300)
  308. # error "Compiler not configured - please reconfigure"
  309. #endif
  310. //
  311. // last known and checked version is 8.1:
  312. #if (BOOST_GCC_VERSION > 80100)
  313. # if defined(BOOST_ASSERT_CONFIG)
  314. # error "Boost.Config is older than your compiler - please check for an updated Boost release."
  315. # else
  316. // we don't emit warnings here anymore since there are no defect macros defined for
  317. // gcc post 3.4, so any failures are gcc regressions...
  318. //# warning "boost: Unknown compiler version - please run the configure tests and report the results"
  319. # endif
  320. #endif