P99
|
◆ P99_GENERIC
Type generic expression in anticipation of C11 This macro expects a syntax that is similar to that of C11's That is an expression EXP, followed by a default value DEF, followed by a list of type value pairs. So here this is an expression that depending on the type of In C11 syntax, the above would be coded with some kind of "label" syntax: _Generic(a,
int*: a,
double*: x);
As you can see above, the default value can be omitted. If omitted, it is replaced with some appropriate expression that should usually give you a syntax error. If there is a default expression, it is used when none of the types matches: a = P99_GENERIC(a + b,
max_uintmax,
(int, max_int),
(long, max_long),
(long long, max_llong),
(float, max_float),
(double, max_double))(a, b);
In C11 syntax a = _Generic(a + b,
default: max_uintmax,
int: max_int,
long: max_long,
long long: max_llong,
float: max_float,
double: max_double)(a, b);
Here all of the expressions evaluate to a function specifier. If
Definition at line 707 of file p99_generic.h. |