eĿlipsis
a language independent preprocessor
 
Loading...
Searching...
No Matches
ellipsis-predefined-c-attribute.h
Go to the documentation of this file.
1// This installs the feature and ensures that eĿlipsis is conforming to C23.
2#define __has_c_attribute___ __has_c_attribute___
3
4// This establishes a mechanism to register attributes. This
5// distinguishes two cases, standard attributes and prefixed
6// attributes. For both we have a mechanism such that also the double
7// underscore versions are handled. For standard attributes this is
8// achieved by binding the macro HSUF to __EXPAND__ and __UGLIFY__,
9// respectively, to produce the two different variants. For prefixed
10// attributes additionally HPRE is bound to these two values, such
11// that in total the four variants are produced.
12//
13// The macro may be called with one, two, or three arguments, where
14// additionally the second and third may be empty.
15//
16#define __HAS_C_ATTRIBUTE(PRE, ...) __HAS_C_ATTRIBUTE_I ## __VA_OPT__(plus) (PRE __VA_OPT__(,) __VA_ARGS__)
17#define __HAS_C_ATTRIBUTE_Iplus(PRE, SUF, ...) __HAS_C_ATTRIBUTE_II ## __VA_OPT__(plus) (PRE, SUF __VA_OPT__(,) __VA_ARGS__)
18
19// If the second argument is empty, the to-be-defined attribute is a
20// standard attribute, named by the first argument. It is an error if
21// the third argument is also empty because standard attributes should
22// always expand to a number that corresponds to a version number
23// date; we can't guess that by ourselves.
24#define __HAS_C_ATTRIBUTE_I(PRE) __HAS_C_ATTRIBUTE_I_(HPRE(PRE), __STRINGIFY__(PRE))
25#define __HAS_C_ATTRIBUTE_I_(PRE, SPRE) \
26 __HAS_C_ATTRIBUTE_MANGLE \
27 (PRE, \
28 , \
29 __ERROR__(standard attribute SPRE: configuration shall be of the form yyyymmL))
30
31
32// If the first and second arguments are present this is a prefixed
33// attribute. A value of 1 is guessed if there is no third argument,
34// because that seems to be the general policy of vendors, here.
35#bind __HAS_C_ATTRIBUTE_II(PRE, SUF) __HAS_C_ATTRIBUTE_MANGLE(PRE, SUF, __ONE__)
36#bind __HAS_C_ATTRIBUTE_IIplus(PRE, SUF, ...) __HAS_C_ATTRIBUTE_MANGLE(PRE, SUF, __VA_ARGS__)
37
38
39#bind __HAS_C_ATTRIBUTE_MANGLE(PRE, SUF, VAL) __HAS_C_ATTRIBUTE_XDEFINE(__HAS_C_ATTRIBUTE_MANGLE2(PRE, SUF), VAL)
40#bind __HAS_C_ATTRIBUTE_XDEFINE(NAME, VAL) __has_c_attribute‿ ## NAME __EVALUATE__(VAL)
41
42#bind __HAS_C_ATTRIBUTE_MANGLE2(PRE, ...) __HAS_C_ATTRIBUTE_MANGLE2_I ## __VA_OPT__(plus) (PRE __VA_OPT__(,) __VA_ARGS__)
43#bind __HAS_C_ATTRIBUTE_MANGLE2_I(NAME) __HAS_C_ATTRIBUTE_MANGLE_(HSUF(NAME))
44#bind __HAS_C_ATTRIBUTE_MANGLE2_Iplus(PRE, ...) __HAS_C_ATTRIBUTE_MANGLE_(HPRE(PRE) :: HSUF(__VA_ARGS__))
45#bind __HAS_C_ATTRIBUTE_MANGLE_(...) __MANGLE__(__VA_ARGS__)