Objective: Application should be able to load a dll dynamically using LoadLibrary and call its exported function using GetProcAddress.
My dll class has a function returning a unique_ptr of the class type.
I want to export this function such that the application can call this function using getProcAddress after dll is loaded successfully.
Using extern "C" will not allow to use a C++ class(unique_ptr class template, in this case) in the function signature.
I know, If do not use extern "C", it will export the function ( via __declspec(dllexport) ) with a mangled name.
The client will not know the mangled name during the call to getProcAddress, so how will a client call this function?
Is there a way to export such a function?
GetProcAddress. And that you use it from a C++ program where you can actually create the objects of the C++ classes. - Some programmer dudestd::unique_ptris implementation-dependent. - MSaltersnewmemory inside the DLL anddeleteit inside the client app if they don't share the same memory manager. Just because the DLL and client are both compiled in any C++ compilers does not guarantee that. Even using the same compiler does not guarantee that. - Remy Lebeaustd::unique_ptrsupports custom deleters, which would be the second C function. - MSalters