3 ms·
That's... not really a problem when you dispatch on pointer types? Like, to fix the example from the article you quote: #define string_length_fixed(x) _Ge
by Joker_vD 2y ago
That's... not really a problem when you dispatch on pointer types? Like, to fix the example from the article you quote:
#define string_length_fixed(x) _Generic(x, \
const char * : strlen((const char*)(x)), \
struct MyStringBuffer * : ((struct MyStringBuffer *)(x))->length)
The discarded branches don't get evaluated so it's perfectly fine.