definition of dllimport function not allowed

守給你的承諾、 提交于 2019-12-01 20:17:53

As documentation states, dllimport function are not allowed to have a body right there.

[...] functions can be declared as dllimports but not defined as dllimports.

// function definition
void __declspec(dllimport) funcB() {}   // C2491

// function declaration
void __declspec(dllimport) funcB();   // OK

You are saying that the function is external, defined in a Dll. And then you are defining it in your code. This is illegal since is has to be one or the other, but not both external and internal.

My guess is that you simply need to change dllimport to dllexport. I assume that you are building this code into a library.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!