调用约定错误!!(ESP的值没有在函数调用中正确保存)



我是在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是一个纯粹的抽象类(接口),您不能初始化抽象类,也不能直接使用其方法。您应该初始化它的导数B_DLL

最新更新