ein
0.0.1
一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1
#pragma once
2
21
30
#ifdef __has_attribute
31
#define ein_has_attribute(x) __has_attribute(x)
32
#else
33
#define ein_has_attribute(__x) 0
34
#endif
35
49
#if defined(_MSC_VER)
50
#define ein_has_declspec_attribute(__x) 1
51
#elif defined(EIN_USE_DECLSPEC) && defined(__has_declspec_attribute)
52
#define ein_has_declspec_attribute(x) __has_declspec_attribute(x)
53
#else
54
#define ein_has_declspec_attribute(__x) 0
55
#endif
56
64
81
#if ein_has_attribute(const)
82
#define ein_const __attribute__((const))
83
#else
84
#define ein_const
85
#endif
86
99
#if ein_has_attribute(pure)
100
#define ein_pure __attribute__((pure))
101
#else
102
#define ein_pure
103
#endif
104
106
113
134
#if ein_has_attribute(lifetimebound)
135
#define ein_lifetimebound [[clang::lifetimebound]]
136
#else
137
#define ein_lifetimebound
138
#endif
139
148
#if ein_has_attribute(noescape)
149
#define ein_noescape __attribute__((noescape))
150
#else
151
#define ein_noescape
152
#endif
153
165
#define ein_nodiscard [[nodiscard]]
166
168
169
178
183
#if ein_has_attribute(always_inline)
184
#define ein_inline inline __attribute__((always_inline))
185
#elif defined _WIN32
186
#define ein_inline __forceinline
187
#else
188
#define ein_inline inline
189
#endif
190
200
#if ein_has_attribute(flatten)
201
#define ein_flatten __attribute__((flatten))
202
#else
203
#define ein_flatten
204
#endif
205
215
#if ein_has_attribute(artificial)
216
#define ein_artificial __attribute__((artificial))
217
#elif ein_has_attribute(__artificial__)
218
#define ein_artificial __attribute__((__artificial__))
219
#else
220
#define ein_artificial
221
#warning "[[artificial]] is not supported"
222
#endif
223
232
#if ein_has_attribute(noinline)
233
#define ein_noinline __attribute__((noinline))
234
#else
235
#define ein_noinline
236
#endif
237
247
#if ein_has_attribute(optnone)
248
#define ein_optnone __attribute__((optnone))
249
#else
250
#define ein_optnone
251
#endif
252
262
271
#if ein_has_attribute(weak)
272
#define ein_weak __attribute__((weak))
273
#else
274
#define ein_weak
275
#endif
276
291
#if ein_has_attribute(internal_linkage)
292
#define ein_internal_linkage __attribute__((internal_linkage))
293
#else
294
#define ein_internal_linkage
295
#endif
296
306
#if __has_cpp_attribute(clang::preferred_name)
307
#define ein_preferred_name(x) [[clang::preferred_name(__x)]]
308
#else
309
#define ein_preferred_name(__x)
310
#endif
311
321
330
#if ein_has_attribute(__visibility__)
331
#define ein_visibility(...) __attribute__((__visibility__(__VA_ARGS__)))
332
#else
333
#define ein_visibility(...)
334
#warning "[[visibility]] is not supported"
335
#endif
336
345
#if ein_has_attribute(exclude_from_explicit_instantiation)
346
#define ein_exclude_from_explicit_instantiation __attribute__((exclude_from_explicit_instantiation))
347
#else
348
#define ein_exclude_from_explicit_instantiation
349
#warning "[[exclude_from_explicit_instantiation]] is not supported"
350
#endif
351
365
#define ein_hidden ein_visibility("hidden") ein_exclude_from_explicit_instantiation
366
368
375
384
#if __cpp_constinit
385
#define ein_constinit constinit
386
#elif ein_has_attribute(require_constant_initialization)
387
#define ein_constinit __attribute__((require_constant_initialization))
388
#else
389
#define ein_constinit
390
#endif
391
400
#if ein_has_attribute(uninitialized)
401
#define ein_uninitialized __attribute__((uninitialized))
402
#else
403
#define ein_uninitialized
404
#endif
405
415
#if __has_cpp_attribute(clang::reinitializes)
416
#define ein_reinitializes [[clang::reinitializes]]
417
#else
418
#define ein_reinitializes
419
#endif
420
src
ein
attributes
common.hpp
© 2024 Edward Kmett. All rights reserved.