]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
b32b8144 FG |
30 | #ifndef __has_cpp_attribute |
31 | #define __has_cpp_attribute(x) 0 | |
32 | #endif | |
33 | ||
7c673cae FG |
34 | #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) |
35 | # define BOOST_NO_EXCEPTIONS | |
36 | #endif | |
37 | ||
38 | #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI) | |
39 | # define BOOST_NO_RTTI | |
40 | #endif | |
41 | ||
42 | #if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID) | |
43 | # define BOOST_NO_TYPEID | |
44 | #endif | |
45 | ||
46 | #if !__has_feature(cxx_thread_local) | |
47 | # define BOOST_NO_CXX11_THREAD_LOCAL | |
48 | #endif | |
49 | ||
50 | #ifdef __is_identifier | |
51 | #if !__is_identifier(__int64) && !defined(__GNUC__) | |
52 | # define BOOST_HAS_MS_INT64 | |
53 | #endif | |
54 | #endif | |
55 | ||
56 | #if __has_include(<stdint.h>) | |
57 | # define BOOST_HAS_STDINT_H | |
58 | #endif | |
59 | ||
92f5a8d4 TL |
60 | #if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) |
61 | #if (__clang_major__ >= 4) && defined(__has_include) | |
62 | #if __has_include(<quadmath.h>) | |
63 | # define BOOST_HAS_FLOAT128 | |
64 | #endif | |
65 | #endif | |
66 | #endif | |
67 | ||
7c673cae FG |
68 | |
69 | #define BOOST_HAS_NRVO | |
70 | ||
71 | // Branch prediction hints | |
b32b8144 | 72 | #if !defined (__c2__) && defined(__has_builtin) |
7c673cae FG |
73 | #if __has_builtin(__builtin_expect) |
74 | #define BOOST_LIKELY(x) __builtin_expect(x, 1) | |
75 | #define BOOST_UNLIKELY(x) __builtin_expect(x, 0) | |
76 | #endif | |
77 | #endif | |
78 | ||
79 | // Clang supports "long long" in all compilation modes. | |
80 | #define BOOST_HAS_LONG_LONG | |
81 | ||
82 | // | |
83 | // We disable this if the compiler is really nvcc with C++03 as it | |
84 | // doesn't actually support __int128 as of CUDA_VERSION=7500 | |
85 | // even though it defines __SIZEOF_INT128__. | |
86 | // See https://svn.boost.org/trac/boost/ticket/10418 | |
87 | // https://svn.boost.org/trac/boost/ticket/11852 | |
88 | // Only re-enable this for nvcc if you're absolutely sure | |
89 | // of the circumstances under which it's supported. | |
90 | // Similarly __SIZEOF_INT128__ is defined when targetting msvc | |
91 | // compatibility even though the required support functions are absent. | |
92 | // | |
93 | #if defined(__CUDACC__) | |
94 | # if defined(BOOST_GCC_CXX11) | |
95 | # define BOOST_NVCC_CXX11 | |
96 | # else | |
97 | # define BOOST_NVCC_CXX03 | |
98 | # endif | |
99 | #endif | |
100 | ||
101 | #if defined(__SIZEOF_INT128__) && !defined(BOOST_NVCC_CXX03) && !defined(_MSC_VER) | |
102 | # define BOOST_HAS_INT128 | |
103 | #endif | |
104 | ||
105 | ||
106 | // | |
107 | // Dynamic shared object (DSO) and dynamic-link library (DLL) support | |
108 | // | |
11fdf7f2 TL |
109 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) |
110 | # define BOOST_HAS_DECLSPEC | |
111 | # define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__)) | |
112 | # define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__)) | |
113 | #else | |
7c673cae | 114 | # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) |
92f5a8d4 | 115 | # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) |
7c673cae | 116 | # define BOOST_SYMBOL_IMPORT |
7c673cae FG |
117 | #endif |
118 | ||
119 | // | |
120 | // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through | |
121 | // between switch labels. | |
122 | // | |
123 | #if __cplusplus >= 201103L && defined(__has_warning) | |
124 | # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") | |
125 | # define BOOST_FALLTHROUGH [[clang::fallthrough]] | |
126 | # endif | |
127 | #endif | |
128 | ||
129 | #if !__has_feature(cxx_auto_type) | |
130 | # define BOOST_NO_CXX11_AUTO_DECLARATIONS | |
131 | # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS | |
132 | #endif | |
133 | ||
134 | // | |
135 | // Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t | |
136 | // | |
137 | #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) | |
138 | # define BOOST_NO_CXX11_CHAR16_T | |
139 | # define BOOST_NO_CXX11_CHAR32_T | |
140 | #endif | |
141 | ||
142 | #if defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(__GNUC__) | |
143 | #define BOOST_HAS_EXPM1 | |
144 | #define BOOST_HAS_LOG1P | |
145 | #endif | |
146 | ||
147 | #if !__has_feature(cxx_constexpr) | |
148 | # define BOOST_NO_CXX11_CONSTEXPR | |
149 | #endif | |
150 | ||
151 | #if !__has_feature(cxx_decltype) | |
152 | # define BOOST_NO_CXX11_DECLTYPE | |
153 | #endif | |
154 | ||
155 | #if !__has_feature(cxx_decltype_incomplete_return_types) | |
156 | # define BOOST_NO_CXX11_DECLTYPE_N3276 | |
157 | #endif | |
158 | ||
159 | #if !__has_feature(cxx_defaulted_functions) | |
160 | # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS | |
161 | #endif | |
162 | ||
163 | #if !__has_feature(cxx_deleted_functions) | |
164 | # define BOOST_NO_CXX11_DELETED_FUNCTIONS | |
165 | #endif | |
166 | ||
167 | #if !__has_feature(cxx_explicit_conversions) | |
168 | # define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS | |
169 | #endif | |
170 | ||
171 | #if !__has_feature(cxx_default_function_template_args) | |
172 | # define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS | |
173 | #endif | |
174 | ||
175 | #if !__has_feature(cxx_generalized_initializers) | |
176 | # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
177 | #endif | |
178 | ||
179 | #if !__has_feature(cxx_lambdas) | |
180 | # define BOOST_NO_CXX11_LAMBDAS | |
181 | #endif | |
182 | ||
183 | #if !__has_feature(cxx_local_type_template_args) | |
184 | # define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS | |
185 | #endif | |
186 | ||
187 | #if !__has_feature(cxx_noexcept) | |
188 | # define BOOST_NO_CXX11_NOEXCEPT | |
189 | #endif | |
190 | ||
191 | #if !__has_feature(cxx_nullptr) | |
192 | # define BOOST_NO_CXX11_NULLPTR | |
193 | #endif | |
194 | ||
195 | #if !__has_feature(cxx_range_for) | |
196 | # define BOOST_NO_CXX11_RANGE_BASED_FOR | |
197 | #endif | |
198 | ||
199 | #if !__has_feature(cxx_raw_string_literals) | |
200 | # define BOOST_NO_CXX11_RAW_LITERALS | |
201 | #endif | |
202 | ||
203 | #if !__has_feature(cxx_reference_qualified_functions) | |
204 | # define BOOST_NO_CXX11_REF_QUALIFIERS | |
205 | #endif | |
206 | ||
207 | #if !__has_feature(cxx_generalized_initializers) | |
208 | # define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX | |
209 | #endif | |
210 | ||
211 | #if !__has_feature(cxx_rvalue_references) | |
212 | # define BOOST_NO_CXX11_RVALUE_REFERENCES | |
213 | #endif | |
214 | ||
215 | #if !__has_feature(cxx_strong_enums) | |
216 | # define BOOST_NO_CXX11_SCOPED_ENUMS | |
217 | #endif | |
218 | ||
219 | #if !__has_feature(cxx_static_assert) | |
220 | # define BOOST_NO_CXX11_STATIC_ASSERT | |
221 | #endif | |
222 | ||
223 | #if !__has_feature(cxx_alias_templates) | |
224 | # define BOOST_NO_CXX11_TEMPLATE_ALIASES | |
225 | #endif | |
226 | ||
227 | #if !__has_feature(cxx_unicode_literals) | |
228 | # define BOOST_NO_CXX11_UNICODE_LITERALS | |
229 | #endif | |
230 | ||
231 | #if !__has_feature(cxx_variadic_templates) | |
232 | # define BOOST_NO_CXX11_VARIADIC_TEMPLATES | |
233 | #endif | |
234 | ||
235 | #if !__has_feature(cxx_user_literals) | |
236 | # define BOOST_NO_CXX11_USER_DEFINED_LITERALS | |
237 | #endif | |
238 | ||
239 | #if !__has_feature(cxx_alignas) | |
240 | # define BOOST_NO_CXX11_ALIGNAS | |
241 | #endif | |
242 | ||
243 | #if !__has_feature(cxx_trailing_return) | |
244 | # define BOOST_NO_CXX11_TRAILING_RESULT_TYPES | |
245 | #endif | |
246 | ||
247 | #if !__has_feature(cxx_inline_namespaces) | |
248 | # define BOOST_NO_CXX11_INLINE_NAMESPACES | |
249 | #endif | |
250 | ||
251 | #if !__has_feature(cxx_override_control) | |
252 | # define BOOST_NO_CXX11_FINAL | |
253 | #endif | |
254 | ||
255 | #if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__)) | |
256 | # define BOOST_NO_CXX14_BINARY_LITERALS | |
257 | #endif | |
258 | ||
259 | #if !__has_feature(__cxx_decltype_auto__) | |
260 | # define BOOST_NO_CXX14_DECLTYPE_AUTO | |
261 | #endif | |
262 | ||
263 | #if !__has_feature(__cxx_aggregate_nsdmi__) | |
264 | # define BOOST_NO_CXX14_AGGREGATE_NSDMI | |
265 | #endif | |
266 | ||
267 | #if !__has_feature(__cxx_init_captures__) | |
268 | # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES | |
269 | #endif | |
270 | ||
271 | #if !__has_feature(__cxx_generic_lambdas__) | |
272 | # define BOOST_NO_CXX14_GENERIC_LAMBDAS | |
273 | #endif | |
274 | ||
275 | // clang < 3.5 has a defect with dependent type, like following. | |
276 | // | |
277 | // template <class T> | |
278 | // constexpr typename enable_if<pred<T> >::type foo(T &) | |
279 | // { } // error: no return statement in constexpr function | |
280 | // | |
281 | // This issue also affects C++11 mode, but C++11 constexpr requires return stmt. | |
282 | // Therefore we don't care such case. | |
283 | // | |
284 | // Note that we can't check Clang version directly as the numbering system changes depending who's | |
285 | // creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873) | |
286 | // so instead verify that we have a feature that was introduced at the same time as working C++14 | |
287 | // constexpr (generic lambda's in this case): | |
288 | // | |
289 | #if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__) | |
290 | # define BOOST_NO_CXX14_CONSTEXPR | |
291 | #endif | |
292 | ||
293 | #if !__has_feature(__cxx_return_type_deduction__) | |
294 | # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION | |
295 | #endif | |
296 | ||
297 | #if !__has_feature(__cxx_variable_templates__) | |
298 | # define BOOST_NO_CXX14_VARIABLE_TEMPLATES | |
299 | #endif | |
300 | ||
b32b8144 FG |
301 | #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) |
302 | # define BOOST_NO_CXX17_STRUCTURED_BINDINGS | |
303 | #endif | |
304 | ||
92f5a8d4 TL |
305 | #if !defined(__cpp_if_constexpr) || (__cpp_if_constexpr < 201606) |
306 | # define BOOST_NO_CXX17_IF_CONSTEXPR | |
307 | #endif | |
308 | ||
b32b8144 FG |
309 | // Clang 3.9+ in c++1z |
310 | #if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L | |
311 | # define BOOST_NO_CXX17_INLINE_VARIABLES | |
312 | # define BOOST_NO_CXX17_FOLD_EXPRESSIONS | |
313 | #endif | |
314 | ||
315 | #if __cplusplus < 201103L | |
316 | #define BOOST_NO_CXX11_SFINAE_EXPR | |
317 | #endif | |
318 | ||
7c673cae FG |
319 | #if __cplusplus < 201400 |
320 | // All versions with __cplusplus above this value seem to support this: | |
321 | # define BOOST_NO_CXX14_DIGIT_SEPARATORS | |
322 | #endif | |
323 | // | |
324 | // __builtin_unreachable: | |
325 | #if defined(__has_builtin) && __has_builtin(__builtin_unreachable) | |
326 | #define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable(); | |
327 | #endif | |
328 | ||
b32b8144 FG |
329 | #if (__clang_major__ == 3) && (__clang_minor__ == 0) |
330 | // Apparently a clang bug: | |
331 | # define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS | |
332 | #endif | |
333 | ||
7c673cae FG |
334 | // Clang has supported the 'unused' attribute since the first release. |
335 | #define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__)) | |
336 | ||
b32b8144 FG |
337 | // Type aliasing hint. |
338 | #if __has_attribute(__may_alias__) | |
339 | # define BOOST_MAY_ALIAS __attribute__((__may_alias__)) | |
340 | #endif | |
341 | ||
7c673cae FG |
342 | #ifndef BOOST_COMPILER |
343 | # define BOOST_COMPILER "Clang version " __clang_version__ | |
344 | #endif | |
345 | ||
346 | // Macro used to identify the Clang compiler. | |
347 | #define BOOST_CLANG 1 | |
348 |