我正在使用一个API,要求我将函数指针作为回调传递.我正在尝试从我的类中使用此API,但是我遇到了编译错误.
这是我从构造函数中做的:
m_cRedundencyManager->Init(this->RedundencyManagerCallBack);
Run Code Online (Sandbox Code Playgroud)
这不编译 - 我收到以下错误:
错误8错误C3867:'CLoggersInfra :: RedundencyManagerCallBack':函数调用缺少参数列表; 使用'&CLoggersInfra :: RedundencyManagerCallBack'创建指向成员的指针
我尝试使用这个建议&CLoggersInfra::RedundencyManagerCallBack- 对我不起作用.
对此有何建议/解释?
我正在使用VS2008.
谢谢!!
想要将boost :: bind传递给期望普通函数指针(相同签名)的方法.
typedef void TriggerProc_type(Variable*,void*);
void InitVariable(TriggerProc_type *proc);
boost::function<void (Variable*, void*)> triggerProc ...
InitVariable(triggerProc);
error C2664: 'InitVariable' : cannot convert parameter 1 from
'boost::function<Signature>' to 'void (__cdecl *)(type *,void *)'
Run Code Online (Sandbox Code Playgroud)
我可以避免存储boost :: function并直接传递绑定的functor,但后来我得到类似的错误:
error C2664: 'blah(void (__cdecl *)(type *,void *))' : cannot convert parameter
1 from 'boost::_bi::bind_t<R,F,L>' to 'void (__cdecl *)(type *,void *)'
Run Code Online (Sandbox Code Playgroud)