Re:Improving _Generic in C2y
by ori_b on Monday August 05, 2024 @03:44AM
(#41158961)
There's a far worse problem: that you effectively need to use it from preprocessor macros, which effectively prevents it from being used from being used maintainable.
[ Parent
| on HN ]
The "interface" would directly expose the specialized and uniquely named functions. _Generic is just an inline helper to automatically select the right specialized function by a type. If C ABI compatibility is required, that's about the only way to do it (for better or worse).
(FWIW I haven't found a compelling reason yet to use _Generic in my own C code)
I don't think there are very many compelling reasons to use it. It's a dead end.
If I can use _Generic, I can get a cleaner interface by directly calling the right function, and skipping the macro mess.