c++ - 调用约定错误!! (ESP 的值未在函数调用中正确保存)

标签 c++ visual-studio-2010 dll calling-convention

我不熟悉用 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/

相关文章:

c++ - 从 C++ 中的结构访问单个成员类型的所有元素

c# - 是否在 C# 项目中包含外部 DLL

c++ - c++中变量的栈内存分配

c++ - opengl中的多纹理添加混合

java - Android 多点触控事件索引

c++ - VC++2010 自动生成方法 stub 或原型(prototype)

visual-studio-2010 - 使用并行 nsight 2.2 创建新的 CUDA 项目

python - *.pyd 文件无法加载,但 DependancyWalker 是干净的,ProcMon 显示它已加载

c# - 调用从 c# 返回 char* 的 c++ dll 函数。不能使用 DllImport()

c++ - 为什么无法识别我重载的乘法运算符?