Is there no way I could avoid name mangling of C++ classes and its member functions when exposed from a c++ dll.
Can\'t I use a def file mechanism in this regard ?
I think the best way to do this is to provide C wrappers around the C++ library. This was quite popular 10 or more years back when I was programming in C++ but I don't know if it is done any more.
Basically, for every class C
, for every constructor ctor
to be exposed to create an extern "C" CPtr cCtor(....)
method that returns an opaque pointer CPtr
and for every function func
to be exposed you create extern "C" cFunc(CPtr,....)
Another approach is to create a CStruct
that has member variables of function pointer types, implement them to call the class methods and let the client do all the hard work.