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 code that double checks if the correct type is passed. The pointer p is passed and along the type of that pointer must be also manually typed in the macro.
The ternary expression will always return the second operand but both second and third operands will be checked if their type matches, and if they don't you should get a compiler error.
A simple example:
int* p = NULL ;
1 ? p : ( float* )p ; //error
1 ? p : ( int* )p ; //ok