1
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
其接受與所述相同的接口,因爲它的函數指針,但我正在此錯誤成員函數。傳遞使用boost ::結合
error: cannot convert boost::function to 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*)
我覺得綁定部分有些問題。你能糾正它嗎?
謝謝。有效。第一次使用ClientData :) – Ashot