P99

◆ P99_GENERIC_PCONST

#define P99_GENERIC_PCONST (   PEXP,
  NCONST,
  CONST 
)
Value:
P99_GENERIC((1 ? (PEXP) : (void volatile*)1),, \
P00_VOID_QUAL_(volatile, NCONST), \
P00_VOID_QUAL_(volatile const, CONST) \
)

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 const qualified or not. If we suppose that for a certain task we want to distinguish const qualified pointers and have already two functions myfunc_ and myfunc_c that handle these two cases we can simply chose like this:

#define myfunc(PEXP) P99_GENERIC_PQUALIFIED((PEXP), myfunc_, myfunc_c)(PEXP)
See also
P99_GENERIC_PQUALIFIED
P99_GENERIC_PVOLATILE
P99_GENERIC_PCONSTVOLATILE
P99_GENERIC_TCONST 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

Definition at line 1586 of file p99_generic.h.

P99_GENERIC
#define P99_GENERIC(...)
Type generic expression in anticipation of C11 _Generic.
Definition: p99_generic.h:707