extern "C" + std::unique_ptr

Flaviu_ 911 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*

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,505 questions
{count} votes