News for hackers. Stuff that matters.
Re:Improving _Generic in C2y by Joker_vD on Sunday August 04, 2024 @11:28PM (#41157939)
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.

There are no comments on this comment yet.