1 // (C) Copyright Douglas Gregor 2010
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)
7 // See http://www.boost.org for most recent version.
9 // Clang compiler setup.
11 #define BOOST_HAS_PRAGMA_ONCE
13 // Detecting `-fms-extension` compiler flag assuming that _MSC_VER defined when that flag is used.
14 #if defined (_MSC_VER) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4))
15 # define BOOST_HAS_PRAGMA_DETECT_MISMATCH
18 // When compiling with clang before __has_extension was defined,
19 // even if one writes 'defined(__has_extension) && __has_extension(xxx)',
20 // clang reports a compiler error. So the only workaround found is:
22 #ifndef __has_extension
23 #define __has_extension __has_feature
26 #ifndef __has_attribute
27 #define __has_attribute(x) 0
30 #ifndef __has_cpp_attribute
31 #define __has_cpp_attribute(x) 0
34 #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS)
35 # define BOOST_NO_EXCEPTIONS
38 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI)
39 # define BOOST_NO_RTTI
42 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID)
43 # define BOOST_NO_TYPEID
46 #if !__has_feature(cxx_thread_local)
47 # define BOOST_NO_CXX11_THREAD_LOCAL
50 #ifdef __is_identifier
51 #if !__is_identifier(__int64) && !defined(__GNUC__)
52 # define BOOST_HAS_MS_INT64
56 #if __has_include(<stdint.h>)
57 # define BOOST_HAS_STDINT_H
61 #define BOOST_HAS_NRVO
63 // Branch prediction hints
64 #if !defined (__c2__) && defined(__has_builtin)
65 #if __has_builtin(__builtin_expect)
66 #define BOOST_LIKELY(x) __builtin_expect(x, 1)
67 #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
71 // Clang supports "long long" in all compilation modes.
72 #define BOOST_HAS_LONG_LONG
75 // We disable this if the compiler is really nvcc with C++03 as it
76 // doesn't actually support __int128 as of CUDA_VERSION=7500
77 // even though it defines __SIZEOF_INT128__.
78 // See https://svn.boost.org/trac/boost/ticket/10418
79 // https://svn.boost.org/trac/boost/ticket/11852
80 // Only re-enable this for nvcc if you're absolutely sure
81 // of the circumstances under which it's supported.
82 // Similarly __SIZEOF_INT128__ is defined when targetting msvc
83 // compatibility even though the required support functions are absent.
85 #if defined(__CUDACC__)
86 # if defined(BOOST_GCC_CXX11)
87 # define BOOST_NVCC_CXX11
89 # define BOOST_NVCC_CXX03
93 #if defined(__SIZEOF_INT128__) && !defined(BOOST_NVCC_CXX03) && !defined(_MSC_VER)
94 # define BOOST_HAS_INT128
99 // Dynamic shared object (DSO) and dynamic-link library (DLL) support
101 #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
102 # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
103 # define BOOST_SYMBOL_IMPORT
104 # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
108 // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
109 // between switch labels.
111 #if __cplusplus >= 201103L && defined(__has_warning)
112 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
113 # define BOOST_FALLTHROUGH [[clang::fallthrough]]
117 #if !__has_feature(cxx_auto_type)
118 # define BOOST_NO_CXX11_AUTO_DECLARATIONS
119 # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
123 // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t
125 #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
126 # define BOOST_NO_CXX11_CHAR16_T
127 # define BOOST_NO_CXX11_CHAR32_T
130 #if defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(__GNUC__)
131 #define BOOST_HAS_EXPM1
132 #define BOOST_HAS_LOG1P
135 #if !__has_feature(cxx_constexpr)
136 # define BOOST_NO_CXX11_CONSTEXPR
139 #if !__has_feature(cxx_decltype)
140 # define BOOST_NO_CXX11_DECLTYPE
143 #if !__has_feature(cxx_decltype_incomplete_return_types)
144 # define BOOST_NO_CXX11_DECLTYPE_N3276
147 #if !__has_feature(cxx_defaulted_functions)
148 # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
151 #if !__has_feature(cxx_deleted_functions)
152 # define BOOST_NO_CXX11_DELETED_FUNCTIONS
155 #if !__has_feature(cxx_explicit_conversions)
156 # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
159 #if !__has_feature(cxx_default_function_template_args)
160 # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
163 #if !__has_feature(cxx_generalized_initializers)
164 # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
167 #if !__has_feature(cxx_lambdas)
168 # define BOOST_NO_CXX11_LAMBDAS
171 #if !__has_feature(cxx_local_type_template_args)
172 # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
175 #if !__has_feature(cxx_noexcept)
176 # define BOOST_NO_CXX11_NOEXCEPT
179 #if !__has_feature(cxx_nullptr)
180 # define BOOST_NO_CXX11_NULLPTR
183 #if !__has_feature(cxx_range_for)
184 # define BOOST_NO_CXX11_RANGE_BASED_FOR
187 #if !__has_feature(cxx_raw_string_literals)
188 # define BOOST_NO_CXX11_RAW_LITERALS
191 #if !__has_feature(cxx_reference_qualified_functions)
192 # define BOOST_NO_CXX11_REF_QUALIFIERS
195 #if !__has_feature(cxx_generalized_initializers)
196 # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
199 #if !__has_feature(cxx_rvalue_references)
200 # define BOOST_NO_CXX11_RVALUE_REFERENCES
203 #if !__has_feature(cxx_strong_enums)
204 # define BOOST_NO_CXX11_SCOPED_ENUMS
207 #if !__has_feature(cxx_static_assert)
208 # define BOOST_NO_CXX11_STATIC_ASSERT
211 #if !__has_feature(cxx_alias_templates)
212 # define BOOST_NO_CXX11_TEMPLATE_ALIASES
215 #if !__has_feature(cxx_unicode_literals)
216 # define BOOST_NO_CXX11_UNICODE_LITERALS
219 #if !__has_feature(cxx_variadic_templates)
220 # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
223 #if !__has_feature(cxx_user_literals)
224 # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
227 #if !__has_feature(cxx_alignas)
228 # define BOOST_NO_CXX11_ALIGNAS
231 #if !__has_feature(cxx_trailing_return)
232 # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
235 #if !__has_feature(cxx_inline_namespaces)
236 # define BOOST_NO_CXX11_INLINE_NAMESPACES
239 #if !__has_feature(cxx_override_control)
240 # define BOOST_NO_CXX11_FINAL
243 #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__))
244 # define BOOST_NO_CXX14_BINARY_LITERALS
247 #if !__has_feature(__cxx_decltype_auto__)
248 # define BOOST_NO_CXX14_DECLTYPE_AUTO
251 #if !__has_feature(__cxx_aggregate_nsdmi__)
252 # define BOOST_NO_CXX14_AGGREGATE_NSDMI
255 #if !__has_feature(__cxx_init_captures__)
256 # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
259 #if !__has_feature(__cxx_generic_lambdas__)
260 # define BOOST_NO_CXX14_GENERIC_LAMBDAS
263 // clang < 3.5 has a defect with dependent type, like following.
265 // template <class T>
266 // constexpr typename enable_if<pred<T> >::type foo(T &)
267 // { } // error: no return statement in constexpr function
269 // This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
270 // Therefore we don't care such case.
272 // Note that we can't check Clang version directly as the numbering system changes depending who's
273 // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873)
274 // so instead verify that we have a feature that was introduced at the same time as working C++14
275 // constexpr (generic lambda's in this case):
277 #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__)
278 # define BOOST_NO_CXX14_CONSTEXPR
281 #if !__has_feature(__cxx_return_type_deduction__)
282 # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
285 #if !__has_feature(__cxx_variable_templates__)
286 # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
289 #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606)
290 # define BOOST_NO_CXX17_STRUCTURED_BINDINGS
293 // Clang 3.9+ in c++1z
294 #if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L
295 # define BOOST_NO_CXX17_INLINE_VARIABLES
296 # define BOOST_NO_CXX17_FOLD_EXPRESSIONS
299 #if __cplusplus < 201103L
300 #define BOOST_NO_CXX11_SFINAE_EXPR
303 #if __cplusplus < 201400
304 // All versions with __cplusplus above this value seem to support this:
305 # define BOOST_NO_CXX14_DIGIT_SEPARATORS
308 // __builtin_unreachable:
309 #if defined(__has_builtin) && __has_builtin(__builtin_unreachable)
310 #define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable();
313 #if (__clang_major__ == 3) && (__clang_minor__ == 0)
314 // Apparently a clang bug:
315 # define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS
318 // Clang has supported the 'unused' attribute since the first release.
319 #define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
321 #ifndef BOOST_COMPILER
322 # define BOOST_COMPILER "Clang version " __clang_version__
325 // Macro used to identify the Clang compiler.
326 #define BOOST_CLANG 1