cfunctiondefaultoverloading

Default values on arguments in C functions and function overloading in C


Converting a C++ lib to ANSI C and it seems like though ANSI C doesn't support default values for function variables or am I mistaken? What I want is something like

int funcName(int foo, bar* = NULL);

Also, is function overloading possible in ANSI C?

Would need

const char* foo_property(foo_t* /* this */, int /* property_number*/);

const char* foo_property(foo_t* /* this */, const char* /* key */, int /* iter */);

Could of course just name them differently but being used to C++ I kinda used to function overloading.


Solution

  • No, Standard C does not support either. Why do you feel you need to convert your C++ code to C? That could get quite tricky - I'd have thought writing wrappers would be the way to go, if your C++ must be callable from C.