P99

◆ P99_GENERIC_PQUALIFIED

#define P99_GENERIC_PQUALIFIED (   PEXP,
  ... 
)
Value:
/* The second case is subtle. If we would chose (void*)0 */ \
/* this would be a null pointer constant and the return */ \
/* type would be the type of PEXP. If it is another type */ \
/* of void* expression the return is a qualified version */ \
/* of void*. */ \
(1 ? (PEXP) : (void*)1),, \
P00_VOIDIFY_LIST(__VA_ARGS__))

Generic choice based on the qualification of the target of a pointer expression.

This can be used to choose a different function to call if the target of a pointer expression is qualified or not. If we suppose that for a certain task we want to distinguish const or volatile qualified pointers and have already different functions myfunc_, myfunc_c, ... that handle these cases we can simply chose like this:

(, myfunc_),
(const, myfunc_c),
(volatile, myfunc_v),
(const volatile, myfunc_cv))
(PEXP)

Or if we want the qualification of a return expression to match the qualification of the target of an input expression

(, tutu),
(const, (tutu_type const*)tutu),
(volatile, (tutu_type volatile*)tutu),
(const volatile, (tutu_type const volatile*)tutu)
)
See also
P99_GENERIC_PCONST
P99_GENERIC_PVOLATILE
P99_GENERIC_PCONSTVOLATILE
P99_GENERIC_TQUALIFIED for a similar macro that works for type expressions instead of a pointer expression
Remarks
argument 0 maybe evaluated several times for its type but only once for its value
argument 1 maybe evaluated several times for its type but only once for its value
argument 2 maybe evaluated several times for its type but only once for its value
argument 3 maybe evaluated several times for its type but only once for its value

Definition at line 1554 of file p99_generic.h.

P99_GENERIC_PQUALIFIED
#define P99_GENERIC_PQUALIFIED(PEXP,...)
Generic choice based on the qualification of the target of a pointer expression.
Definition: p99_generic.h:1554
P99_GENERIC
#define P99_GENERIC(...)
Type generic expression in anticipation of C11 _Generic.
Definition: p99_generic.h:707