
extern "C" Interface* DLLCreate() { return new InterfaceImpl; }
extern "C" void DLLDestroy( Interface* p ) { delete p; }
and then construct an InterfacePtr( DLLCreate(), DLLDestroy ). You'll need a public virtual destructor in this case, though.
I changed my code to this: void DLLCreate( Interface& rInterface ) { // Implementation option #1: rInterface.reset( new InterfaceImple ); // Implementation option #2: rInterface = InterfacePtr( new InterfaceImpl ); } Is this a valid solution as well? At least it compiles - but with the first solution I have the feeling that I could run into the boundary problem, since the actual pointer is not constructed on the DLL side. But as I said - I can only guess here... Is there a difference between both solutions?
Yes, it's allowed. Since you are using the DLL runtime, you probably don't need to interoperate with different C++ compilers so you probably need to just omit the extern "C" from DLLCreate. But how can I load the function than after it got mangled?
-Dirk PS: Sorry for the wrong post...

Dirk Gregorius wrote:
I changed my code to this:
void DLLCreate( Interface& rInterface ) { // Implementation option #1: rInterface.reset( new InterfaceImple );
// Implementation option #2: rInterface = InterfacePtr( new InterfaceImpl ); }
Is this a valid solution as well?
Yes, it's a valid solution. Didn't occur to me that references to classes would be allowed in extern "C".
But how can I load the function than after it got mangled?
You can use the mangled name. Something like ?DLLCreate@@YA?AV?$shared_ptr@VInterface@@@boost@@XZ. :-)

Yes, it's a valid solution. Didn't occur to me that references to classes would be allowed in extern "C". Didn't think about that issue, but that is correct. So I change to use a pointer instead of the reference. This should be correct than...
But how can I load the function than after it got mangled?
You can use the mangled name. Something like ?DLLCreate <at> <at> YA?AV?$shared_ptr <at> VInterface <at> <at> <at> boost <at> <at> XZ. :-)
participants (2)
-
Dirk Gregorius
-
Peter Dimov