lundi 5 juillet 2021

Error "linkage specification is not allowed" when using extern "C" with __declspec(dllexport) in a C++ class

When I am using using extern "C" with __declspec(dllexport) in the Class, then I am getting an error "linkage specification is not allowed".

If i declare this outside of the class then i am not getting any error.

Could someone please help me how to use extern "C" with __declspec(dllexport) with in the Class

Below is the code snippet:

#ifdef _WIN32
#define DECLSPEC extern "C" __declspec(dllexport)
#else
#define DECLSPEC __declspec(dllimport)
#endif

class MyClass
{
DECLSPEC static std::shared_ptr<ITestInterface> GetInstance();
};

Aucun commentaire:

Enregistrer un commentaire