繁体   English   中英

C ++函数指针错误

[英]C++ Function pointer error

我正在尝试使源代码正常工作

extern "C" {
    typedef LRESULT (__stdcall *NRI_PM_CALLBACK)(WPARAM, LPARAM);
}

LRESULT OnPaymentManagerMessage(WPARAM wParam, LPARAM lParam)
{
    int type = (wParam >> 4) & 0x0F;
    int device = wParam & 0x0F;
    //cstr.Format("** Msg **[ %d %d %d ]", type, device, lParam);
    //handle message here
    return lParam;
}

NRI_PM_CALLBACK callback = &OnPaymentManagerMessage; //error on this line 

错误:类型“ LRESULT(*)(WPARAM wParam,LPARAM lParam)”的值不能用于初始化“ NRI_PM_CALLBACK”类型的实体

我正在Visual Studio Express 2012中运行它

有什么想法吗?

谢谢

使OnPaymentManagerMessage()成为__stdcall函数:

LRESULT __stdcall OnPaymentManagerMessage(WPARAM wParam, LPARAM lParam) 
/* ... */

__cdecl是编译器的默认设置(尽管编译器选项可以更改该设置)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM