gcc.hpp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. #if !defined(__CUDACC__)
  17. #define BOOST_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  18. #endif
  19. #if __GNUC__ == 3
  20. # if defined (__PATHSCALE__)
  21. # define BOOST_NO_TWO_PHASE_NAME_LOOKUP
  22. # define BOOST_NO_IS_ABSTRACT
  23. # endif
  24. # if __GNUC_MINOR__ < 4
  25. # define BOOST_NO_IS_ABSTRACT
  26. # endif
  27. # define BOOST_NO_CXX11_EXTERN_TEMPLATE
  28. #endif
  29. #if __GNUC__ < 4
  30. //
  31. // All problems to gcc-3.x and earlier here:
  32. //
  33. #define BOOST_NO_TWO_PHASE_NAME_LOOKUP
  34. # ifdef __OPEN64__
  35. # define BOOST_NO_IS_ABSTRACT
  36. # endif
  37. #endif
  38. // GCC prior to 3.4 had #pragma once too but it didn't work well with filesystem links
  39. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
  40. #define BOOST_HAS_PRAGMA_ONCE
  41. #endif
  42. #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )
  43. // Previous versions of GCC did not completely implement value-initialization:
  44. // GCC Bug 30111, "Value-initialization of POD base class doesn't initialize
  45. // members", reported by Jonathan Wakely in 2006,
  46. // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 (fixed for GCC 4.4)
  47. // GCC Bug 33916, "Default constructor fails to initialize array members",
  48. // reported by Michael Elizabeth Chastain in 2007,
  49. // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 (fixed for GCC 4.2.4)
  50. // See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues
  51. #define BOOST_NO_COMPLETE_VALUE_INITIALIZATION
  52. #endif
  53. #if !defined(__EXCEPTIONS) && !defined(BOOST_NO_EXCEPTIONS)
  54. # define BOOST_NO_EXCEPTIONS
  55. #endif
  56. //
  57. // Threading support: Turn this on unconditionally here (except for
  58. // those platforms where we can know for sure). It will get turned off again
  59. // later if no threading API is detected.
  60. //
  61. #if !defined(__MINGW32__) && !defined(linux) && !defined(__linux) && !defined(__linux__)
  62. # define BOOST_HAS_THREADS
  63. #endif
  64. //
  65. // gcc has "long long"
  66. //
  67. #define BOOST_HAS_LONG_LONG
  68. //
  69. // gcc implements the named return value optimization since version 3.1
  70. //
  71. #define BOOST_HAS_NRVO
  72. // Branch prediction hints
  73. #define BOOST_LIKELY(x) __builtin_expect(x, 1)
  74. #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
  75. //
  76. // Dynamic shared object (DSO) and dynamic-link library (DLL) support
  77. //
  78. #if __GNUC__ >= 4
  79. # if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && !defined(__CYGWIN__)
  80. // All Win32 development environments, including 64-bit Windows and MinGW, define
  81. // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment,
  82. // so does not define _WIN32 or its variants.
  83. # define BOOST_HAS_DECLSPEC
  84. # define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__))
  85. # define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__))
  86. # else
  87. # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
  88. # define BOOST_SYMBOL_IMPORT
  89. # endif
  90. # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
  91. #else
  92. // config/platform/win32.hpp will define BOOST_SYMBOL_EXPORT, etc., unless already defined
  93. # define BOOST_SYMBOL_EXPORT
  94. #endif
  95. //
  96. // RTTI and typeinfo detection is possible post gcc-4.3:
  97. //
  98. #if __GNUC__ * 100 + __GNUC_MINOR__ >= 403
  99. # ifndef __GXX_RTTI
  100. # ifndef BOOST_NO_TYPEID
  101. # define BOOST_NO_TYPEID
  102. # endif
  103. # ifndef BOOST_NO_RTTI
  104. # define BOOST_NO_RTTI
  105. # endif
  106. # endif
  107. #endif
  108. //
  109. // Recent GCC versions have __int128 when in 64-bit mode.
  110. //
  111. // We disable this if the compiler is really nvcc as it
  112. // doesn't actually support __int128 as of CUDA_VERSION=5000
  113. // even though it defines __SIZEOF_INT128__.
  114. // See https://svn.boost.org/trac/boost/ticket/8048
  115. // Only re-enable this for nvcc if you're absolutely sure
  116. // of the circumstances under which it's supported:
  117. //
  118. #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__)
  119. # define BOOST_HAS_INT128
  120. #endif
  121. // C++0x features in 4.3.n and later
  122. //
  123. #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
  124. // C++0x features are only enabled when -std=c++0x or -std=gnu++0x are
  125. // passed on the command line, which in turn defines
  126. // __GXX_EXPERIMENTAL_CXX0X__.
  127. # define BOOST_HAS_DECLTYPE
  128. # define BOOST_HAS_RVALUE_REFS
  129. # define BOOST_HAS_STATIC_ASSERT
  130. # define BOOST_HAS_VARIADIC_TMPL
  131. #else
  132. # define BOOST_NO_CXX11_DECLTYPE
  133. # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
  134. # define BOOST_NO_CXX11_RVALUE_REFERENCES
  135. # define BOOST_NO_CXX11_STATIC_ASSERT
  136. // Variadic templates compiler:
  137. // http://www.generic-programming.org/~dgregor/cpp/variadic-templates.html
  138. # if defined(__VARIADIC_TEMPLATES) || (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4) && defined(__GXX_EXPERIMENTAL_CXX0X__))
  139. # define BOOST_HAS_VARIADIC_TMPL
  140. # else
  141. # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
  142. # endif
  143. #endif
  144. // C++0x features in 4.4.n and later
  145. //
  146. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  147. # define BOOST_NO_CXX11_AUTO_DECLARATIONS
  148. # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
  149. # define BOOST_NO_CXX11_CHAR16_T
  150. # define BOOST_NO_CXX11_CHAR32_T
  151. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  152. # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
  153. # define BOOST_NO_CXX11_DELETED_FUNCTIONS
  154. # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
  155. # define BOOST_NO_CXX11_INLINE_NAMESPACES
  156. #endif
  157. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
  158. # define BOOST_NO_SFINAE_EXPR
  159. #endif
  160. // GCC 4.5 forbids declaration of defaulted functions in private or protected sections
  161. #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 5)
  162. # define BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS
  163. #endif
  164. // C++0x features in 4.5.0 and later
  165. //
  166. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  167. # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
  168. # define BOOST_NO_CXX11_LAMBDAS
  169. # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
  170. # define BOOST_NO_CXX11_RAW_LITERALS
  171. # define BOOST_NO_CXX11_UNICODE_LITERALS
  172. #endif
  173. // C++0x features in 4.5.1 and later
  174. //
  175. #if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40501) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  176. // scoped enums have a serious bug in 4.4.0, so define BOOST_NO_CXX11_SCOPED_ENUMS before 4.5.1
  177. // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38064
  178. # define BOOST_NO_CXX11_SCOPED_ENUMS
  179. #endif
  180. // C++0x features in 4.6.n and later
  181. //
  182. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  183. #define BOOST_NO_CXX11_CONSTEXPR
  184. #define BOOST_NO_CXX11_NOEXCEPT
  185. #define BOOST_NO_CXX11_NULLPTR
  186. #define BOOST_NO_CXX11_RANGE_BASED_FOR
  187. #define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
  188. #endif
  189. // C++0x features in 4.7.n and later
  190. //
  191. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  192. # define BOOST_NO_CXX11_TEMPLATE_ALIASES
  193. # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
  194. #endif
  195. // C++0x features in 4.8.n and later
  196. //
  197. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  198. # define BOOST_NO_CXX11_ALIGNAS
  199. #endif
  200. // C++0x features in 4.8.1 and later
  201. //
  202. #if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40801) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
  203. # define BOOST_NO_CXX11_DECLTYPE_N3276
  204. #endif
  205. #ifndef BOOST_COMPILER
  206. # define BOOST_COMPILER "GNU C++ version " __VERSION__
  207. #endif
  208. // ConceptGCC compiler:
  209. // http://www.generic-programming.org/software/ConceptGCC/
  210. #ifdef __GXX_CONCEPTS__
  211. # define BOOST_HAS_CONCEPTS
  212. # define BOOST_COMPILER "ConceptGCC version " __VERSION__
  213. #endif
  214. // versions check:
  215. // we don't know gcc prior to version 3.30:
  216. #if (__GNUC__ < 3) || (__GNUC__ == 3 && (__GNUC_MINOR__ < 3))
  217. # error "Compiler not configured - please reconfigure"
  218. #endif
  219. //
  220. // last known and checked version is 4.6 (Pre-release):
  221. #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6))
  222. # if defined(BOOST_ASSERT_CONFIG)
  223. # error "Unknown compiler version - please run the configure tests and report the results"
  224. # else
  225. // we don't emit warnings here anymore since there are no defect macros defined for
  226. // gcc post 3.4, so any failures are gcc regressions...
  227. //# warning "Unknown compiler version - please run the configure tests and report the results"
  228. # endif
  229. #endif