我不熟悉用 C++ 创建 DLL 库,这是我的代码
//header.h
class A
{
virtual int funct()=0; //Pure virtual function
};
项目 B(在编译时生成 DLL)
#include "header.h"
#define B_DLL __declspec( dllexport )
class B_DLL B: public A
{
//Definitions of the 3 pure virtual functions are here
int funct()
{
//definition go here
}
};
现在我创建一个类 A 的实例并调用 funct() 然后我得到错误
Run-Time Check Failure #0 - The value of ESP was not properly saved across a
function call. This is usually a result of calling a function declared with
one calling convention with a function pointer declared with a different calling
convention.
如何使用调用约定 _cdecl 或 _stdcall 来解决这个问题。我搜索了很多但是找不到确切的解决方法请帮助我解决这个问题
提前致谢
最佳答案
A
是一个纯抽象类(接口(interface)),不能初始化抽象类也不能直接使用它的方法。您应该改为初始化它的派生B_DLL
。
关于c++ - 调用约定错误!! (ESP 的值未在函数调用中正确保存),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17481654/