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 | |
7 | // See http://www.boost.org for most recent version. |
8 | |
9 | // Clang compiler setup. |
10 | |
11 | #define BOOST_HAS_PRAGMA_ONCE |
12 | |
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 |
16 | #endif |
17 | |
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: |
21 | |
22 | #ifndef __has_extension |
23 | #define __has_extension __has_feature |
24 | #endif |
25 | |
26 | #ifndef __has_attribute |
27 | #define __has_attribute(x) 0 |
28 | #endif |
29 | |
30 | #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) |
31 | # define BOOST_NO_EXCEPTIONS |
32 | #endif |
33 | |
34 | #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI) |
35 | # define BOOST_NO_RTTI |
36 | #endif |
37 | |
38 | #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID) |
39 | # define BOOST_NO_TYPEID |
40 | #endif |
41 | |
42 | #if defined(__int64) && !defined(__GNUC__) |
43 | # define BOOST_HAS_MS_INT64 |
44 | #endif |
45 | |
46 | #define BOOST_HAS_NRVO |
47 | |
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) |
53 | #endif |
54 | #endif |
55 | |
56 | // Clang supports "long long" in all compilation modes. |
57 | #define BOOST_HAS_LONG_LONG |
58 | |
59 | // |
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. |
68 | // |
69 | #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) && !defined(_MSC_VER) |
70 | # define BOOST_HAS_INT128 |
71 | #endif |
72 | |
73 | |
74 | // |
75 | // Dynamic shared object (DSO) and dynamic-link library (DLL) support |
76 | // |
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"))) |
81 | #endif |
82 | |
83 | // |
84 | // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through |
85 | // between switch labels. |
86 | // |
87 | #if __cplusplus >= 201103L && defined(__has_warning) |
88 | # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") |
89 | # define BOOST_FALLTHROUGH [[clang::fallthrough]] |
90 | # endif |
91 | #endif |
92 | |
93 | #if !__has_feature(cxx_auto_type) |
94 | # define BOOST_NO_CXX11_AUTO_DECLARATIONS |
95 | # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS |
96 | #endif |
97 | |
98 | // |
99 | // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t |
100 | // |
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 |
104 | #endif |
105 | |
106 | #if !__has_feature(cxx_constexpr) |
107 | # define BOOST_NO_CXX11_CONSTEXPR |
108 | #endif |
109 | |
110 | #if !__has_feature(cxx_decltype) |
111 | # define BOOST_NO_CXX11_DECLTYPE |
112 | #endif |
113 | |
114 | #if !__has_feature(cxx_decltype_incomplete_return_types) |
115 | # define BOOST_NO_CXX11_DECLTYPE_N3276 |
116 | #endif |
117 | |
118 | #if !__has_feature(cxx_defaulted_functions) |
119 | # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS |
120 | #endif |
121 | |
122 | #if !__has_feature(cxx_deleted_functions) |
123 | # define BOOST_NO_CXX11_DELETED_FUNCTIONS |
124 | #endif |
125 | |
126 | #if !__has_feature(cxx_explicit_conversions) |
127 | # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS |
128 | #endif |
129 | |
130 | #if !__has_feature(cxx_default_function_template_args) |
131 | # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS |
132 | #endif |
133 | |
134 | #if !__has_feature(cxx_generalized_initializers) |
135 | # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST |
136 | #endif |
137 | |
138 | #if !__has_feature(cxx_lambdas) |
139 | # define BOOST_NO_CXX11_LAMBDAS |
140 | #endif |
141 | |
142 | #if !__has_feature(cxx_local_type_template_args) |
143 | # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS |
144 | #endif |
145 | |
146 | #if !__has_feature(cxx_noexcept) |
147 | # define BOOST_NO_CXX11_NOEXCEPT |
148 | #endif |
149 | |
150 | #if !__has_feature(cxx_nullptr) |
151 | # define BOOST_NO_CXX11_NULLPTR |
152 | #endif |
153 | |
154 | #if !__has_feature(cxx_range_for) |
155 | # define BOOST_NO_CXX11_RANGE_BASED_FOR |
156 | #endif |
157 | |
158 | #if !__has_feature(cxx_raw_string_literals) |
159 | # define BOOST_NO_CXX11_RAW_LITERALS |
160 | #endif |
161 | |
162 | #if !__has_feature(cxx_reference_qualified_functions) |
163 | # define BOOST_NO_CXX11_REF_QUALIFIERS |
164 | #endif |
165 | |
166 | #if !__has_feature(cxx_generalized_initializers) |
167 | # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX |
168 | #endif |
169 | |
170 | #if !__has_feature(cxx_rvalue_references) |
171 | # define BOOST_NO_CXX11_RVALUE_REFERENCES |
172 | #endif |
173 | |
174 | #if !__has_feature(cxx_strong_enums) |
175 | # define BOOST_NO_CXX11_SCOPED_ENUMS |
176 | #endif |
177 | |
178 | #if !__has_feature(cxx_static_assert) |
179 | # define BOOST_NO_CXX11_STATIC_ASSERT |
180 | #endif |
181 | |
182 | #if !__has_feature(cxx_alias_templates) |
183 | # define BOOST_NO_CXX11_TEMPLATE_ALIASES |
184 | #endif |
185 | |
186 | #if !__has_feature(cxx_unicode_literals) |
187 | # define BOOST_NO_CXX11_UNICODE_LITERALS |
188 | #endif |
189 | |
190 | #if !__has_feature(cxx_variadic_templates) |
191 | # define BOOST_NO_CXX11_VARIADIC_TEMPLATES |
192 | #endif |
193 | |
194 | #if !__has_feature(cxx_user_literals) |
195 | # define BOOST_NO_CXX11_USER_DEFINED_LITERALS |
196 | #endif |
197 | |
198 | #if !__has_feature(cxx_alignas) |
199 | # define BOOST_NO_CXX11_ALIGNAS |
200 | #endif |
201 | |
202 | #if !__has_feature(cxx_trailing_return) |
203 | # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES |
204 | #endif |
205 | |
206 | #if !__has_feature(cxx_inline_namespaces) |
207 | # define BOOST_NO_CXX11_INLINE_NAMESPACES |
208 | #endif |
209 | |
210 | #if !__has_feature(cxx_override_control) |
211 | # define BOOST_NO_CXX11_FINAL |
212 | #endif |
213 | |
214 | #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__)) |
215 | # define BOOST_NO_CXX14_BINARY_LITERALS |
216 | #endif |
217 | |
218 | #if !__has_feature(__cxx_decltype_auto__) |
219 | # define BOOST_NO_CXX14_DECLTYPE_AUTO |
220 | #endif |
221 | |
222 | #if !__has_feature(__cxx_aggregate_nsdmi__) |
223 | # define BOOST_NO_CXX14_AGGREGATE_NSDMI |
224 | #endif |
225 | |
226 | #if !__has_feature(__cxx_init_captures__) |
227 | # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES |
228 | #endif |
229 | |
230 | #if !__has_feature(__cxx_generic_lambdas__) |
231 | # define BOOST_NO_CXX14_GENERIC_LAMBDAS |
232 | #endif |
233 | |
234 | // clang < 3.5 has a defect with dependent type, like following. |
235 | // |
236 | // template <class T> |
237 | // constexpr typename enable_if<pred<T> >::type foo(T &) |
238 | // { } // error: no return statement in constexpr function |
239 | // |
240 | // This issue also affects C++11 mode, but C++11 constexpr requires return stmt. |
241 | // Therefore we don't care such case. |
242 | // |
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): |
247 | // |
248 | #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__) |
249 | # define BOOST_NO_CXX14_CONSTEXPR |
250 | #endif |
251 | |
252 | #if !__has_feature(__cxx_return_type_deduction__) |
253 | # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION |
254 | #endif |
255 | |
256 | #if !__has_feature(__cxx_variable_templates__) |
257 | # define BOOST_NO_CXX14_VARIABLE_TEMPLATES |
258 | #endif |
259 | |
260 | #if __cplusplus < 201400 |
261 | // All versions with __cplusplus above this value seem to support this: |
262 | # define BOOST_NO_CXX14_DIGIT_SEPARATORS |
263 | #endif |
264 | // |
265 | // __builtin_unreachable: |
266 | #if defined(__has_builtin) && __has_builtin(__builtin_unreachable) |
267 | #define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable(); |
268 | #endif |
269 | |
270 | // Clang has supported the 'unused' attribute since the first release. |
271 | #define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__)) |
272 | |
273 | #ifndef BOOST_COMPILER |
274 | # define BOOST_COMPILER "Clang version " __clang_version__ |
275 | #endif |
276 | |
277 | // Macro used to identify the Clang compiler. |
278 | #define BOOST_CLANG 1 |
279 | |
280 | |