c语言中函数esp,C运行时检查失败#0 – ESP的值未在函数调用中正确保存

在尝试使用C语言通过动态链接库mtb.dll调用函数时遇到了Run-Time Check Failure #0错误。该错误通常由于在不同调用约定间不匹配的函数指针调用导致。代码中加载了mtb.dll并尝试获取InitMotoBee、SetMotors和Digital_IO三个函数的地址。问题可能出在函数指针类型定义与实际库函数的调用约定不符。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我正在尝试用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 a function pointer declared

with a different calling convention.

这是我的代码.

#include "stdafx.h"

#include

#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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值