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 #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS)
31 # define BOOST_NO_EXCEPTIONS
34 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI)
35 # define BOOST_NO_RTTI
38 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID)
39 # define BOOST_NO_TYPEID
42 #if defined(__int64) && !defined(__GNUC__)
43 # define BOOST_HAS_MS_INT64
46 #define BOOST_HAS_NRVO
48 // Branch prediction hints
49 #if defined(__has_builtin)
50 #if __has_builtin(__builtin_expect)
51 #define BOOST_LIKELY(x) __builtin_expect(x, 1)
52 #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
56 // Clang supports "long long" in all compilation modes.
57 #define BOOST_HAS_LONG_LONG
60 // We disable this if the compiler is really nvcc as it
61 // doesn't actually support __int128 as of CUDA_VERSION=5000
62 // even though it defines __SIZEOF_INT128__.
63 // See https://svn.boost.org/trac/boost/ticket/10418
64 // Only re-enable this for nvcc if you're absolutely sure
65 // of the circumstances under which it's supported.
66 // Similarly __SIZEOF_INT128__ is defined when targetting msvc
67 // compatibility even though the required support functions are absent.
69 #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) && !defined(_MSC_VER)
70 # define BOOST_HAS_INT128
75 // Dynamic shared object (DSO) and dynamic-link library (DLL) support
77 #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
78 # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
79 # define BOOST_SYMBOL_IMPORT
80 # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
84 // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
85 // between switch labels.
87 #if __cplusplus >= 201103L && defined(__has_warning)
88 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
89 # define BOOST_FALLTHROUGH [[clang::fallthrough]]
93 #if !__has_feature(cxx_auto_type)
94 # define BOOST_NO_CXX11_AUTO_DECLARATIONS
95 # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
99 // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t
101 #if defined(_MSC_VER) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
102 # define BOOST_NO_CXX11_CHAR16_T
103 # define BOOST_NO_CXX11_CHAR32_T
106 #if !__has_feature(cxx_constexpr)
107 # define BOOST_NO_CXX11_CONSTEXPR
110 #if !__has_feature(cxx_decltype)
111 # define BOOST_NO_CXX11_DECLTYPE
114 #if !__has_feature(cxx_decltype_incomplete_return_types)
115 # define BOOST_NO_CXX11_DECLTYPE_N3276
118 #if !__has_feature(cxx_defaulted_functions)
119 # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
122 #if !__has_feature(cxx_deleted_functions)
123 # define BOOST_NO_CXX11_DELETED_FUNCTIONS
126 #if !__has_feature(cxx_explicit_conversions)
127 # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
130 #if !__has_feature(cxx_default_function_template_args)
131 # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
134 #if !__has_feature(cxx_generalized_initializers)
135 # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
138 #if !__has_feature(cxx_lambdas)
139 # define BOOST_NO_CXX11_LAMBDAS
142 #if !__has_feature(cxx_local_type_template_args)
143 # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
146 #if !__has_feature(cxx_noexcept)
147 # define BOOST_NO_CXX11_NOEXCEPT
150 #if !__has_feature(cxx_nullptr)
151 # define BOOST_NO_CXX11_NULLPTR
154 #if !__has_feature(cxx_range_for)
155 # define BOOST_NO_CXX11_RANGE_BASED_FOR
158 #if !__has_feature(cxx_raw_string_literals)
159 # define BOOST_NO_CXX11_RAW_LITERALS
162 #if !__has_feature(cxx_reference_qualified_functions)
163 # define BOOST_NO_CXX11_REF_QUALIFIERS
166 #if !__has_feature(cxx_generalized_initializers)
167 # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
170 #if !__has_feature(cxx_rvalue_references)
171 # define BOOST_NO_CXX11_RVALUE_REFERENCES
174 #if !__has_feature(cxx_strong_enums)
175 # define BOOST_NO_CXX11_SCOPED_ENUMS
178 #if !__has_feature(cxx_static_assert)
179 # define BOOST_NO_CXX11_STATIC_ASSERT
182 #if !__has_feature(cxx_alias_templates)
183 # define BOOST_NO_CXX11_TEMPLATE_ALIASES
186 #if !__has_feature(cxx_unicode_literals)
187 # define BOOST_NO_CXX11_UNICODE_LITERALS
190 #if !__has_feature(cxx_variadic_templates)
191 # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
194 #if !__has_feature(cxx_user_literals)
195 # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
198 #if !__has_feature(cxx_alignas)
199 # define BOOST_NO_CXX11_ALIGNAS
202 #if !__has_feature(cxx_trailing_return)
203 # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
206 #if !__has_feature(cxx_inline_namespaces)
207 # define BOOST_NO_CXX11_INLINE_NAMESPACES
210 #if !__has_feature(cxx_override_control)
211 # define BOOST_NO_CXX11_FINAL
214 #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__))
215 # define BOOST_NO_CXX14_BINARY_LITERALS
218 #if !__has_feature(__cxx_decltype_auto__)
219 # define BOOST_NO_CXX14_DECLTYPE_AUTO
222 #if !__has_feature(__cxx_aggregate_nsdmi__)
223 # define BOOST_NO_CXX14_AGGREGATE_NSDMI
226 #if !__has_feature(__cxx_init_captures__)
227 # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
230 #if !__has_feature(__cxx_generic_lambdas__)
231 # define BOOST_NO_CXX14_GENERIC_LAMBDAS
234 // clang < 3.5 has a defect with dependent type, like following.
236 // template <class T>
237 // constexpr typename enable_if<pred<T> >::type foo(T &)
238 // { } // error: no return statement in constexpr function
240 // This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
241 // Therefore we don't care such case.
243 // Note that we can't check Clang version directly as the numbering system changes depending who's
244 // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873)
245 // so instead verify that we have a feature that was introduced at the same time as working C++14
246 // constexpr (generic lambda's in this case):
248 #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__)
249 # define BOOST_NO_CXX14_CONSTEXPR
252 #if !__has_feature(__cxx_return_type_deduction__)
253 # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
256 #if !__has_feature(__cxx_variable_templates__)
257 # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
260 #if __cplusplus < 201400
261 // All versions with __cplusplus above this value seem to support this:
262 # define BOOST_NO_CXX14_DIGIT_SEPARATORS
265 // __builtin_unreachable:
266 #if defined(__has_builtin) && __has_builtin(__builtin_unreachable)
267 #define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable();
270 // Clang has supported the 'unused' attribute since the first release.
271 #define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
273 #ifndef BOOST_COMPILER
274 # define BOOST_COMPILER "Clang version " __clang_version__
277 // Macro used to identify the Clang compiler.
278 #define BOOST_CLANG 1