4 ms·
This is indeed one of the two ways to get "generics" in C. The other way is to set up a set of #defines before #including a file, so the #defines rename everyt
by eqvinox 6y ago
This is indeed one of the two ways to get "generics" in C.
The other way is to set up a set of #defines before #including a file, so the #defines rename everything in the include. (The include can also be included multiple times in this pattern.) The latter seems to be more rare.
- kevin_thibedeau 6y agoC11 added _Generic for overloading by type.
- eqvinox 6y ago... which you use inside of a #define :) Like, #define foo_generic(x) _Generic(x, ...) [what I intend to say with this post: _Generic in no way replaces #define, in fact it is designed to work with it.]