xlcpp.hpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. // (C) Copyright Douglas Gregor 2010
  2. //
  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. // compiler setup for IBM XL C/C++ for Linux (Little Endian) based on clang.
  8. #define BOOST_HAS_PRAGMA_ONCE
  9. // Detecting `-fms-extension` compiler flag assuming that _MSC_VER defined when that flag is used.
  10. #if defined (_MSC_VER) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4))
  11. # define BOOST_HAS_PRAGMA_DETECT_MISMATCH
  12. #endif
  13. // When compiling with clang before __has_extension was defined,
  14. // even if one writes 'defined(__has_extension) && __has_extension(xxx)',
  15. // clang reports a compiler error. So the only workaround found is:
  16. #ifndef __has_extension
  17. #define __has_extension __has_feature
  18. #endif
  19. #ifndef __has_cpp_attribute
  20. #define __has_cpp_attribute(x) 0
  21. #endif
  22. #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS)
  23. # define BOOST_NO_EXCEPTIONS
  24. #endif
  25. #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI)
  26. # define BOOST_NO_RTTI
  27. #endif
  28. #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID)
  29. # define BOOST_NO_TYPEID
  30. #endif
  31. #if defined(__int64) && !defined(__GNUC__)
  32. # define BOOST_HAS_MS_INT64
  33. #endif
  34. #define BOOST_HAS_NRVO
  35. // Branch prediction hints
  36. #if defined(__has_builtin)
  37. #if __has_builtin(__builtin_expect)
  38. #define BOOST_LIKELY(x) __builtin_expect(x, 1)
  39. #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
  40. #endif
  41. #endif
  42. // Clang supports "long long" in all compilation modes.
  43. #define BOOST_HAS_LONG_LONG
  44. //
  45. // Dynamic shared object (DSO) and dynamic-link library (DLL) support
  46. //
  47. #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
  48. # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
  49. # define BOOST_SYMBOL_IMPORT
  50. # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
  51. #endif
  52. //
  53. // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
  54. // between switch labels.
  55. //
  56. #if __cplusplus >= 201103L && defined(__has_warning)
  57. # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
  58. # define BOOST_FALLTHROUGH [[clang::fallthrough]]
  59. # endif
  60. #endif
  61. #if !__has_feature(cxx_auto_type)
  62. # define BOOST_NO_CXX11_AUTO_DECLARATIONS
  63. # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
  64. #endif
  65. //
  66. // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t
  67. //
  68. #if defined(_MSC_VER) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
  69. # define BOOST_NO_CXX11_CHAR16_T
  70. # define BOOST_NO_CXX11_CHAR32_T
  71. #endif
  72. #if !__has_feature(cxx_constexpr)
  73. # define BOOST_NO_CXX11_CONSTEXPR
  74. #endif
  75. #if !__has_feature(cxx_decltype)
  76. # define BOOST_NO_CXX11_DECLTYPE
  77. #endif
  78. #if !__has_feature(cxx_decltype_incomplete_return_types)
  79. # define BOOST_NO_CXX11_DECLTYPE_N3276
  80. #endif
  81. #if !__has_feature(cxx_defaulted_functions)
  82. # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
  83. #endif
  84. #if !__has_feature(cxx_deleted_functions)
  85. # define BOOST_NO_CXX11_DELETED_FUNCTIONS
  86. #endif
  87. #if !__has_feature(cxx_explicit_conversions)
  88. # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
  89. #endif
  90. #if !__has_feature(cxx_default_function_template_args)
  91. # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
  92. #endif
  93. #if !__has_feature(cxx_generalized_initializers)
  94. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  95. #endif
  96. #if !__has_feature(cxx_lambdas)
  97. # define BOOST_NO_CXX11_LAMBDAS
  98. #endif
  99. #if !__has_feature(cxx_local_type_template_args)
  100. # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
  101. #endif
  102. #if !__has_feature(cxx_noexcept)
  103. # define BOOST_NO_CXX11_NOEXCEPT
  104. #endif
  105. #if !__has_feature(cxx_nullptr)
  106. # define BOOST_NO_CXX11_NULLPTR
  107. #endif
  108. #if !__has_feature(cxx_range_for)
  109. # define BOOST_NO_CXX11_RANGE_BASED_FOR
  110. #endif
  111. #if !__has_feature(cxx_raw_string_literals)
  112. # define BOOST_NO_CXX11_RAW_LITERALS
  113. #endif
  114. #if !__has_feature(cxx_reference_qualified_functions)
  115. # define BOOST_NO_CXX11_REF_QUALIFIERS
  116. #endif
  117. #if !__has_feature(cxx_generalized_initializers)
  118. # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
  119. #endif
  120. #if !__has_feature(cxx_rvalue_references)
  121. # define BOOST_NO_CXX11_RVALUE_REFERENCES
  122. #endif
  123. #if !__has_feature(cxx_strong_enums)
  124. # define BOOST_NO_CXX11_SCOPED_ENUMS
  125. #endif
  126. #if !__has_feature(cxx_static_assert)
  127. # define BOOST_NO_CXX11_STATIC_ASSERT
  128. #endif
  129. #if !__has_feature(cxx_alias_templates)
  130. # define BOOST_NO_CXX11_TEMPLATE_ALIASES
  131. #endif
  132. #if !__has_feature(cxx_unicode_literals)
  133. # define BOOST_NO_CXX11_UNICODE_LITERALS
  134. #endif
  135. #if !__has_feature(cxx_variadic_templates)
  136. # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
  137. #endif
  138. #if !__has_feature(cxx_user_literals)
  139. # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
  140. #endif
  141. #if !__has_feature(cxx_alignas)
  142. # define BOOST_NO_CXX11_ALIGNAS
  143. #endif
  144. #if !__has_feature(cxx_trailing_return)
  145. # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
  146. #endif
  147. #if !__has_feature(cxx_inline_namespaces)
  148. # define BOOST_NO_CXX11_INLINE_NAMESPACES
  149. #endif
  150. #if !__has_feature(cxx_override_control)
  151. # define BOOST_NO_CXX11_FINAL
  152. #endif
  153. #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__))
  154. # define BOOST_NO_CXX14_BINARY_LITERALS
  155. #endif
  156. #if !__has_feature(__cxx_decltype_auto__)
  157. # define BOOST_NO_CXX14_DECLTYPE_AUTO
  158. #endif
  159. #if !__has_feature(__cxx_aggregate_nsdmi__)
  160. # define BOOST_NO_CXX14_AGGREGATE_NSDMI
  161. #endif
  162. #if !__has_feature(__cxx_init_captures__)
  163. # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
  164. #endif
  165. #if !__has_feature(__cxx_generic_lambdas__)
  166. # define BOOST_NO_CXX14_GENERIC_LAMBDAS
  167. #endif
  168. // clang < 3.5 has a defect with dependent type, like following.
  169. //
  170. // template <class T>
  171. // constexpr typename enable_if<pred<T> >::type foo(T &)
  172. // { } // error: no return statement in constexpr function
  173. //
  174. // This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
  175. // Therefore we don't care such case.
  176. //
  177. // Note that we can't check Clang version directly as the numbering system changes depending who's
  178. // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873)
  179. // so instead verify that we have a feature that was introduced at the same time as working C++14
  180. // constexpr (generic lambda's in this case):
  181. //
  182. #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__)
  183. # define BOOST_NO_CXX14_CONSTEXPR
  184. #endif
  185. #if !__has_feature(__cxx_return_type_deduction__)
  186. # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
  187. #endif
  188. #if !__has_feature(__cxx_variable_templates__)
  189. # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
  190. #endif
  191. #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606)
  192. # define BOOST_NO_CXX17_STRUCTURED_BINDINGS
  193. #endif
  194. #if !defined(__cpp_if_constexpr) || (__cpp_if_constexpr < 201606)
  195. # define BOOST_NO_CXX17_IF_CONSTEXPR
  196. #endif
  197. // Clang 3.9+ in c++1z
  198. #if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L
  199. # define BOOST_NO_CXX17_INLINE_VARIABLES
  200. # define BOOST_NO_CXX17_FOLD_EXPRESSIONS
  201. #endif
  202. #if !__has_feature(cxx_thread_local)
  203. # define BOOST_NO_CXX11_THREAD_LOCAL
  204. #endif
  205. #if __cplusplus < 201400
  206. // All versions with __cplusplus above this value seem to support this:
  207. # define BOOST_NO_CXX14_DIGIT_SEPARATORS
  208. #endif
  209. // Unused attribute:
  210. #if defined(__GNUC__) && (__GNUC__ >= 4)
  211. # define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
  212. #endif
  213. // Type aliasing hint.
  214. #if __has_attribute(__may_alias__)
  215. # define BOOST_MAY_ALIAS __attribute__((__may_alias__))
  216. #endif
  217. #ifndef BOOST_COMPILER
  218. # define BOOST_COMPILER "Clang version " __clang_version__
  219. #endif
  220. // Macro used to identify the Clang compiler.
  221. #define BOOST_CLANG 1