似乎无法为_set_se_translator找到正确的参数

Cannot seem to come up with right parameter for _set_se_translator

本文关键字:参数 translator se set      更新时间:2023-10-16

我正在尝试实现_set_se_translator。我试图用以下签名编写一个函数(来自我的.cpp文件——当然,我的.h文件中也有类似的签名(:

 void CIntersonBScan::trans_func(unsigned int u, EXCEPTION_POINTERS* pExp)

然后,我通过编写以下代码将此函数作为参数传递给_set_se_translator:

 _set_se_translator(&CIntersonBScan::trans_func);

然后我编译我的代码并得到以下错误消息:

错误C2664:"_set_se_translator":无法将参数1从"void(__thiscall CIntersonBScan::*((unsigned int,EXCEPTION_POINTERS*("转换为"_se_translator_function">

在eh.h文件中,我找到了_se_translator_function的以下定义:

 typedef void (__cdecl *_se_translator_function)(unsigned int, struct _EXCEPTION_POINTERS*);

我尝试更改trans_func的签名,但仍然收到相同的错误消息。我已经设置了/EHa编译选项。如何创建一个与_se_translator_function的签名实际匹配的函数?

typedef void (__cdecl *_se_translator_function)(unsigned int, struct _EXCEPTION_POINTERS*);

这必须是一个自由函数或静态成员函数-它不能是非静态成员函数(因为它们有一个隐藏的隐式this参数-并且不能与_se_translator_function匹配(。

它需要是一个独立的函数,而不是成员函数。这就是为什么类型不匹配的原因。