C运行时检查失败#0 – ESP的值未在函数调用中正确保存
发布时间:2020-12-16 03:19:06 所属栏目:百科 来源:网络整理
导读:我正在尝试用c编程motorbee 当我运行代码时,我收到以下错误: 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
我正在尝试用c编程motorbee
当我运行代码时,我收到以下错误:
这是我的代码. #include "stdafx.h" #include <iostream> #include "windows.h" #include "mt.h" using namespace std; HINSTANCE BeeHandle= LoadLibrary("mtb.dll"); Type_InitMotoBee InitMotoBee; Type_SetMotors SetMotors; Type_Digital_IO Digital_IO; void main () { InitMotoBee = (Type_InitMotoBee)GetProcAddress( BeeHandle,"InitMotoBee"); SetMotors =(Type_SetMotors)GetProcAddress(BeeHandle,"SetMotors"); Digital_IO =(Type_Digital_IO)GetProcAddress(BeeHandle,"Digital_IO "); InitMotoBee(); SetMotors(0,50,0); } 解决方法
您的typedef函数指针需要匹配您正在使用的库的
calling convention.例如,如果InitMotoBee使用
cdecl ,则typedef将如下所示:
typedef bool (__cdecl *Type_InitMotoBee)(void) SetMotors函数接受参数,因此也需要正确设置调用约定(这可能是应用程序失败的地方). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |