一位朋友给我发了他的线程课。 现在我只想运行一个侦听器,但线程不希望接受该函数。 我想执行该功能(在static class Networks
中定义)THREAD listen(void* args)
。 THREAD
是#define THREAD unsigned __stdcall
函数不想接受我的观点?
Networks::init() {
listenerth = thread();
listenerth.run(listen, NULL, "listener");
}
在class thread
他定义为run
void run(THREAD func(void*), void* args, const char* pname);
我怎样才能像跑听在另一个线程要么?
错误消息: main.cpp(19):error C3867:'Networks :: listen':函数调用缺少参数列表;使用“&网络::听”创建一个指向成员
但是当我将鼠标移动到错误的地方(符号听),它让我这个在工具提示(当然,MS VC++):
unsigned int __stdcall Networks::listen(void* data)
Error: argument of type "unsigned int (__stdcall Networks::*)(void *data)" is incompatible with parameter of type "unsigned int (__stdcall )(void)"
你也应该发布编译器给你的确切的错误信息。 – Axarydax 2010-06-27 07:30:05
[这个答案]的第一个代码示例(http://stackoverflow.com/questions/3108631/how-to-pass-a-pointer-to-a-member-function-to-ac-function/3108745# 3108745)的帮助? – sbi 2010-06-27 08:04:31
[使用C++类成员函数作为C回调函数]可能的重复(http://stackoverflow.com/questions/1000663/using-ac-class-member-function-as-ac-callback-function) – 2010-06-27 08:41:14