Export entire class through c++ interface

后端 未结 1 1178
眼角桃花
眼角桃花 2021-01-29 14:02

Ok, I\'ll rewrite the question(s). 1. Is it enough to do

class __declspec(dllexport) CXyz {
public:
int Food() {printf(\"Food\\n\");}
};

So th

相关标签:
1条回答
  • 2021-01-29 14:33
    1. Not enough. On the client side CXyz must be declared as __declspec(dllimport). This is usually done by conditional compilation, when some macro is expanded to __declspec(dllexport) in Dll, and to __declspec(dllimport) in a client project. Create sample Dll using VS Application Wizard, check "Export symbols" on one of the Wizard steps, and see, how it is done. And of course, client project should be linked with server .lib file, and server Dll should be available at runtime.

    2. Only class members (and possibly vtable) are allocated. Class methods on Assembly level are global functions with hidden "this" parameter.

    0 讨论(0)
提交回复
热议问题