useless expression in typesaft_cb_cast
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)" ?
Yubin
_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan
Quoted 11 lines · Yubin Ruan
Hi,
typesaft_cb_cast()is defined intypesaft_cb.has:#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.
_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan