extern "C" + std::unique_ptr

Flaviu_ 1,031 Reputation points
2020-12-09T13:29:47.4+00:00

Is there possible to return from a DLL a unique pointer ? I have tried this:

extern "C" __declspec(dllexport) std::unique_ptr<int*> __cdecl SomeMethod(const char* type)
{
    return nullptr;
}

and I got:

error C2526: 'SomeMethod': C linkage function cannot return C++ class 'std::unique_ptr<int *,std::default_delete<_Ty>>'

I wonder whether is possible that. Is it ?

Of course, in the real code is another object type than int*

Developer technologies | C++
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.