我在编程过程中有一个DLL,里面有一个回调函数,而此DLL我不想用隐式调用,就用了显式调用,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这是为什么,在隐式调用时不会出这样的错啊。
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这是为什么,在隐式调用时不会出这样的错啊。
.h文件里
typedef void (CALLBACK * FireEventCallBack)();typedef void (SetEventNotifyCallBackProc)( FireEventCallBack procFireEvent );void api_SetEventNotifyCallBackProc( FireEventCallBack procFireEvent );.c文件里
void CALLBACK MyFireEventCallBack()
{
printf("abcd\n");
}api_SetEventNotifyCallBackProc( FireEventCallBack procFireEvent )
{
SetEventNotifyCallBackProc * pFun =
(SetEventNotifyCallBackProc *)GetDllProcAddr("api_SetEventNotifyCallBackProc");
if(NULL != pFun)
{
pFun(procFireEvent);
}
}
声明的时候加入参数压栈方式修饰符,或者修改编译配置中的默认函数参数压栈方式