I write code in C99 and compile via GCC. I would like to use function overloading for stylistic reasons (otherwise I would have to do name mangling by myself).
I have read Is there a reason that C99 doesn't support function overloading? however, I still wonder whether it can be enabled in GCC.
Can you help me at this point?
No, there is no function overloading in C99, not even in silly GCC extensions. C11 adds _Generic
, but even then you still have to mangle names yourself.
void foo_int(int x);
void foo_double(double x);
#define foo(arg) _Generic((arg), int: foo_int, double: foo_double)(arg)
Whether that's better or worse, well. It's C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With