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