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 #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS)
27 # define BOOST_NO_EXCEPTIONS
30 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI)
31 # define BOOST_NO_RTTI
34 #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID)
35 # define BOOST_NO_TYPEID
38 #if defined(__int64) && !defined(__GNUC__)
39 # define BOOST_HAS_MS_INT64
42 #define BOOST_HAS_NRVO
44 // Branch prediction hints
45 #if defined(__has_builtin)
46 #if __has_builtin(__builtin_expect)
47 #define BOOST_LIKELY(x) __builtin_expect(x, 1)
48 #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
52 // Clang supports "long long" in all compilation modes.
53 #define BOOST_HAS_LONG_LONG
56 // We disable this if the compiler is really nvcc as it
57 // doesn't actually support __int128 as of CUDA_VERSION=5000
58 // even though it defines __SIZEOF_INT128__.
59 // See https://svn.boost.org/trac/boost/ticket/10418
60 // Only re-enable this for nvcc if you're absolutely sure
61 // of the circumstances under which it's supported:
63 #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__)
64 # define BOOST_HAS_INT128
69 // Dynamic shared object (DSO) and dynamic-link library (DLL) support
71 #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
72 # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
73 # define BOOST_SYMBOL_IMPORT
74 # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
78 // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
79 // between switch labels.
81 #if __cplusplus >= 201103L && defined(__has_warning)
82 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
83 # define BOOST_FALLTHROUGH [[clang::fallthrough]]
87 #if !__has_feature(cxx_auto_type)
88 # define BOOST_NO_CXX11_AUTO_DECLARATIONS
89 # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
93 // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t
95 #if defined(_MSC_VER) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
96 # define BOOST_NO_CXX11_CHAR16_T
97 # define BOOST_NO_CXX11_CHAR32_T
100 #if !__has_feature(cxx_constexpr)
101 # define BOOST_NO_CXX11_CONSTEXPR
104 #if !__has_feature(cxx_decltype)
105 # define BOOST_NO_CXX11_DECLTYPE
108 #if !__has_feature(cxx_decltype_incomplete_return_types)
109 # define BOOST_NO_CXX11_DECLTYPE_N3276
112 #if !__has_feature(cxx_defaulted_functions)
113 # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
116 #if !__has_feature(cxx_deleted_functions)
117 # define BOOST_NO_CXX11_DELETED_FUNCTIONS
120 #if !__has_feature(cxx_explicit_conversions)
121 # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
124 #if !__has_feature(cxx_default_function_template_args)
125 # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
128 #if !__has_feature(cxx_generalized_initializers)
129 # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
132 #if !__has_feature(cxx_lambdas)
133 # define BOOST_NO_CXX11_LAMBDAS
136 #if !__has_feature(cxx_local_type_template_args)
137 # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
140 #if !__has_feature(cxx_noexcept)
141 # define BOOST_NO_CXX11_NOEXCEPT
144 #if !__has_feature(cxx_nullptr)
145 # define BOOST_NO_CXX11_NULLPTR
148 #if !__has_feature(cxx_range_for)
149 # define BOOST_NO_CXX11_RANGE_BASED_FOR
152 #if !__has_feature(cxx_raw_string_literals)
153 # define BOOST_NO_CXX11_RAW_LITERALS
156 #if !__has_feature(cxx_reference_qualified_functions)
157 # define BOOST_NO_CXX11_REF_QUALIFIERS
160 #if !__has_feature(cxx_generalized_initializers)
161 # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
164 #if !__has_feature(cxx_rvalue_references)
165 # define BOOST_NO_CXX11_RVALUE_REFERENCES
168 #if !__has_feature(cxx_strong_enums)
169 # define BOOST_NO_CXX11_SCOPED_ENUMS
172 #if !__has_feature(cxx_static_assert)
173 # define BOOST_NO_CXX11_STATIC_ASSERT
176 #if !__has_feature(cxx_alias_templates)
177 # define BOOST_NO_CXX11_TEMPLATE_ALIASES
180 #if !__has_feature(cxx_unicode_literals)
181 # define BOOST_NO_CXX11_UNICODE_LITERALS
184 #if !__has_feature(cxx_variadic_templates)
185 # define BOOST_NO_CXX11_VARIADIC_TEMPLATES
188 #if !__has_feature(cxx_user_literals)
189 # define BOOST_NO_CXX11_USER_DEFINED_LITERALS
192 #if !__has_feature(cxx_alignas)
193 # define BOOST_NO_CXX11_ALIGNAS
196 #if !__has_feature(cxx_trailing_return)
197 # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
200 #if !__has_feature(cxx_inline_namespaces)
201 # define BOOST_NO_CXX11_INLINE_NAMESPACES
204 #if !__has_feature(cxx_override_control)
205 # define BOOST_NO_CXX11_FINAL
208 #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__))
209 # define BOOST_NO_CXX14_BINARY_LITERALS
212 #if !__has_feature(__cxx_decltype_auto__)
213 # define BOOST_NO_CXX14_DECLTYPE_AUTO
216 #if !__has_feature(__cxx_aggregate_nsdmi__)
217 # define BOOST_NO_CXX14_AGGREGATE_NSDMI
220 #if !__has_feature(__cxx_init_captures__)
221 # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES
224 #if !__has_feature(__cxx_generic_lambdas__)
225 # define BOOST_NO_CXX14_GENERIC_LAMBDAS
228 // clang < 3.5 has a defect with dependent type, like following.
230 // template <class T>
231 // constexpr typename enable_if<pred<T> >::type foo(T &)
232 // { } // error: no return statement in constexpr function
234 // This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
235 // Therefore we don't care such case.
237 // Note that we can't check Clang version directly as the numbering system changes depending who's
238 // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873)
239 // so instead verify that we have a feature that was introduced at the same time as working C++14
240 // constexpr (generic lambda's in this case):
242 #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__)
243 # define BOOST_NO_CXX14_CONSTEXPR
246 #if !__has_feature(__cxx_return_type_deduction__)
247 # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
250 #if !__has_feature(__cxx_variable_templates__)
251 # define BOOST_NO_CXX14_VARIABLE_TEMPLATES
254 #if __cplusplus < 201400
255 // All versions with __cplusplus above this value seem to support this:
256 # define BOOST_NO_CXX14_DIGIT_SEPARATORS
261 #if defined(__GNUC__) && (__GNUC__ >= 4)
262 # define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
265 #ifndef BOOST_COMPILER
266 # define BOOST_COMPILER "Clang version " __clang_version__
269 // Macro used to identify the Clang compiler.
270 #define BOOST_CLANG 1