Is this legal to do? I want to export a C function, but internally that function will use a C++ class.
extern "C" BOOL /*BOOL==int*/ Func()
{
return someclass::getinstance()->Func(); // this is just bool tho
}
Answer
This is perfectly legitimate. The purpose of extern "C" is to prevent Func() from getting its name mangled (decorated with type information) so that a C module can link to it using its plain name. C++ mangles names so that functions with the same name but different parameter lists can be resolved (function overloading).
No comments:
Post a Comment