xlcpp.hpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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_alignof)
  145. # define BOOST_NO_CXX11_ALIGNOF
  146. #endif
  147. #if !__has_feature(cxx_trailing_return)
  148. # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
  149. #endif
  150. #if !__has_feature(cxx_inline_namespaces)
  151. # define BOOST_NO_CXX11_INLINE_NAMESPACES
  152. #endif
  153. #if !__has_feature(cxx_override_control)
  154. # define BOOST_NO_CXX11_FINAL
  155. # define BOOST_NO_CXX11_OVERRIDE
  156. #endif
  157. #if !__has_feature(cxx_unrestricted_unions)
  158. # define BOOST_NO_CXX11_UNRESTRICTED_UNION
  159. #endif
  160. #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__))
  161. # define BOOST_NO_CXX14_BINARY_LITERALS
  162. #endif
  163. #if !__has_feature(__cxx_decltype_auto__)
  164. # define BOOST_NO_CXX14_DECLTYPE_AUTO
  165. #endif
  166. #if !__has_feature(__cxx_aggregate_nsdmi__)
  167. # define BOOST_NO_CXX14_AGGREGATE_NSDMI
  168. #endif
  169. #if !__has_feature(__cxx_init_captures__)
  170. # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
  171. #endif
  172. #if !__has_feature(__cxx_generic_lambdas__)
  173. # define BOOST_NO_CXX14_GENERIC_LAMBDAS
  174. #endif
  175. // clang < 3.5 has a defect with dependent type, like following.
  176. //
  177. // template <class T>
  178. // constexpr typename enable_if<pred<T> >::type foo(T &)
  179. // { } // error: no return statement in constexpr function
  180. //
  181. // This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
  182. // Therefore we don't care such case.
  183. //
  184. // Note that we can't check Clang version directly as the numbering system changes depending who's
  185. // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873)
  186. // so instead verify that we have a feature that was introduced at the same time as working C++14
  187. // constexpr (generic lambda's in this case):
  188. //
  189. #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__)
  190. # define BOOST_NO_CXX14_CONSTEXPR
  191. #endif
  192. #if !__has_feature(__cxx_return_type_deduction__)
  193. # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
  194. #endif
  195. #if !__has_feature(__cxx_variable_templates__)
  196. # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
  197. #endif
  198. #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606)
  199. # define BOOST_NO_CXX17_STRUCTURED_BINDINGS
  200. #endif
  201. #if !defined(__cpp_if_constexpr) || (__cpp_if_constexpr < 201606)
  202. # define BOOST_NO_CXX17_IF_CONSTEXPR
  203. #endif
  204. // Clang 3.9+ in c++1z
  205. #if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L
  206. # define BOOST_NO_CXX17_INLINE_VARIABLES
  207. # define BOOST_NO_CXX17_FOLD_EXPRESSIONS
  208. #endif
  209. #if !defined(__cpp_nontype_template_parameter_auto) || (__cpp_nontype_template_parameter_auto < 201606)
  210. # define BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS
  211. #endif
  212. #if !__has_feature(cxx_thread_local)
  213. # define BOOST_NO_CXX11_THREAD_LOCAL
  214. #endif
  215. #if __cplusplus < 201400
  216. // All versions with __cplusplus above this value seem to support this:
  217. # define BOOST_NO_CXX14_DIGIT_SEPARATORS
  218. #endif
  219. // Deprecated symbol markup
  220. #if __has_attribute(deprecated)
  221. #define BOOST_DEPRECATED(msg) __attribute__((deprecated(msg)))
  222. #endif
  223. // Unused attribute:
  224. #if defined(__GNUC__) && (__GNUC__ >= 4)
  225. # define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
  226. #endif
  227. // Type aliasing hint.
  228. #if __has_attribute(__may_alias__)
  229. # define BOOST_MAY_ALIAS __attribute__((__may_alias__))
  230. #endif
  231. #ifndef BOOST_COMPILER
  232. # define BOOST_COMPILER "Clang version " __clang_version__
  233. #endif
  234. // Macro used to identify the Clang compiler.
  235. #define BOOST_CLANG 1
  236. #define BOOST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)