3 ms·
Yes, C doesn't have generics. In practice most C code uses the fourth version, and you just have to remember not to put things with side effects as macro argume
by TorKlingberg 12y ago
Yes, C doesn't have generics. In practice most C code uses the fourth version, and you just have to remember not to put things with side effects as macro arguments.
#define MIN(a, b) ((a) < (b) ? (a) : (b))
C11 does introduce very limited type-variant macros.
- mitchty 12y agoYep, but for min the C11 generics would work just as well and allow for a bit more flexibility than the older approaches. Though you do have to name mangle manually and they aren't quite as powerful as you'd probably want. http://www.robertgamble.net/2012/01/c11-generic-selections.html http://www.robertgamble.net/2012/01/c11-generic-selections.h...