[ccan] useless expression in typesaft_cb_cast
Rusty Russell
rusty at rustcorp.com.au
Tue Mar 13 20:49:45 AEDT 2018
Yubin Ruan <ablacktshirt at gmail.com> writes:
> Hi,
>
> typesaft_cb_cast() is defined in typesaft_cb.h as:
>
> #define typesafe_cb_cast(desttype, oktype, expr) \
> __builtin_choose_expr( \
> __builtin_types_compatible_p(__typeof__(0?(expr):(expr)), \
> oktype), \
> (desttype)(expr), (expr))
>
> what is the point of that "0?(expr):(expr)" ?
Hi Yubin!
I had to search through git history to find it! It serves to
decay a function type to a function pointer, otherwise
__builtin_types_compatible_p(func, functype) returns false because
func isn't a pointer to a function, it's a function.
Cheers,
Rusty.
More information about the ccan
mailing list