struct AAA {
char* myTraceProc(ClientData clientData, Tcl_Interp* interp, const char* name1, const char* name2, int flags) {
return NULL;
}
};
int main(int argc, char* argv[]) {
Tcl_FindExecutable(argv[0]);
Tcl_Interp* interp = Tcl_CreateInterp();
AAA obj;
boost::function<char*(ClientData, Tcl_Interp*, const char*, const char*, int)> f = boost::bind(&AAA::myTraceProc, &obj, _1, _2, _3, _4, _5);
Tcl_TraceVar(interp, "database", TCL_TRACE_WRITES, f, 0);
return 0;
}
在这段代码中,我试图传递AAA::myTraceProc
给Tcl_TraceVar
which 接受与它具有相同接口的函数指针,但我收到了这个错误。
错误:无法将 boost::function 转换为 char* ( )(void , Tcl_Interp*, const char*, const char*, int) for argument 4 to int Tcl_TraceVar(Tcl_Interp*, const char*, int, char* ( )( void , Tcl_Interp*, const char*, const char*, int), void*)
我认为绑定部分有问题。你能纠正一下吗?