J
Jared Ahern
Hello,
I have a C library with several functions that do the same operation
on different input types. These functions can be used in C++ with
'extern "C"'. It would be nice to overload them; here is the way I
presently go about it:
extern "C" int foo_int(int const &);
extern "C" int foo_float(float const &);
int foo(int const & a) { return foo_int(a); };
int foo(float const & a) { return foo_float(a); };
Is there a way to accomplish this without actually creating the
wrapper functions? (Perhaps a way to create portable name-mangled
aliases?) The ability to access the original C names from C++
afterward is not required. My concern is not so much the amount of
code but rather the nested function calls, which could possibly
contribute to a performance hit.
Sorry if this has been addressed before, I didn't happen to find it!
Thanks,
Jared
I have a C library with several functions that do the same operation
on different input types. These functions can be used in C++ with
'extern "C"'. It would be nice to overload them; here is the way I
presently go about it:
extern "C" int foo_int(int const &);
extern "C" int foo_float(float const &);
int foo(int const & a) { return foo_int(a); };
int foo(float const & a) { return foo_float(a); };
Is there a way to accomplish this without actually creating the
wrapper functions? (Perhaps a way to create portable name-mangled
aliases?) The ability to access the original C names from C++
afterward is not required. My concern is not so much the amount of
code but rather the nested function calls, which could possibly
contribute to a performance hit.
Sorry if this has been addressed before, I didn't happen to find it!
Thanks,
Jared