I was looking at some preprocessor macros used in OpenSSL, and I came across the following from crypto/stack/safestack.h
:
#define CHECKED_STACK_OF(t
It's a static assertion about the function type before the cast, providing a type-safe cast.
From C11 (n1570) 6.5.15 (from the constraints section)
Conditional operator
(3) One of the following shall hold for the second and third operands:
- [omitted non-pointer stuff]
- both operands are pointers to qualified or unqualified versions of compatible types;
- one operand is a pointer and the other is a null pointer constant; or
- one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of
void
.
The third operand is a pointer to a function (so the last bullet never applies), so this compiles (without a warning) only if either p
is a null pointer constant or of a type compatible with void (*)(type)
for the last macro (after conversion to a function pointer, if p
is a function designator).