The value of ESP was not properly saved across a function call
来源:互联网 发布:linux下qt编程入门 编辑:程序博客网 时间:2024/05/22 04:45
场景:
这次遇上这个错误: The value of ESP was not properly saved across a function call
我还认为自己传参有问题,其实不是啊。
遇到了问题,就要顺着问题去查。不能退缩啊。
具体原因分析如下:
调用DLL函数,出现错误
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.
错误原因:
你定义函数指针原型时出错。
其实你定义的没有错,但是编译器不认识而已,因为你调用的dll函数是一个远函数,而且是一个C函数,你得告诉编译器它是个c函数才行。那么你就可以在定义该函数的时候加上一句话,
FAR PASCAL 或者 __stdcall 这个就OK了。
具体做法:
比如说你要定义一个 返回类型为空,参数为空的函数指针:
typedef void (*LPFUN)(void);
这样确实跟我们dll里的函数匹配了,上面也说了,我们应该添上几个字,告诉编译器这个是一个远的C函数。
typedef void (WINAPI *LPFUN)(void);
typedef void (__stdcall *LPFUN)(void);
typedef void (FAR PASCAL *LPFUN) (void);
像上面这样定义就OK了,如果用的是VC++,那么直接用第一种定义就ok了。
注意,上面是使用 MFC (DLL)的做法。
如果是WIN32 DLL,得相应的去掉WINAPI ,__stdcall ,FAR PASCAL 这几个参数。因为WIN32 DLL 默认的入栈方式为 __cedcall方式,不是__stdcall方式。
具体的组合方式太多了,反正知道错误的原因是声明相应的函数未匹配就行了。
- DLL 调用错误 -The value of ESP was not properly saved across a function call.
- dynamic DLL 调用错误 -The value of ESP was not properly saved across a function call
- DLL 调用错误 -The value of ESP was not properly saved across a function call.
- The value of ESP was not properly saved across a function call
- The value of ESP was not properly saved across a function call.
- The value of ESP was not properly saved across a function call解决方案
- 【Debug】The value of ESP was not properly saved across a function call.
- The value of ESP was not properly saved across a function call.
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
- The value of ESP was not properly saved across a function call的问题 2010-9-26 18:57
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. 错误解决
- Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
- DLL 调用错误 -The value of ESP was not properly saved across a function cal
- 经常光顾的IOS开发网站
- 倒排索引讲解
- c# xml字符串 反序列化为实例对象
- Linux 系统中用户切换
- 模板方法
- The value of ESP was not properly saved across a function call
- ios_OC中的类声明、定义域等等概念
- ThinkPHP 中的 Session 使用笔记和说明
- Java EJB到底是什么?
- MySQL查询本周、上周、本月、上个月份的数据
- 国达色谱仪器 全能型顶空进样器
- IO三种方式:BIO,NIO,AIO (异步读写asynchronous IO)
- Java8 Lamdba表达式 001
- Visual.C#.2010从入门到精通].(Visual.C#.2010.Step.By.Step)读书笔记 值、引用(七)