下面有我的代碼的一部分:創建Thread類
class MyClass
{
...
HANDLE m_ListenThr;
DWORD WINAPI ListenThread (LPVOID WorkContext);
bool CreateListenThreads();
}
bool MyClass::CreateListenThreads()
{
...
m_ListenThr = CreateThread(NULL, 0, MyClass::ListenThread,(void*)this, 0,&dwThreadId);
}
DWORD WINAPI MyClass::ListenThread (LPVOID WorkThreadContext)
{
MyClass pThis = reinterpret_cast<MyClass*>(WorkThreadContext);
...
}
編譯後,我得到這個錯誤:
error C3867: 'MyClass::ListenThread': function call missing argument list; use '&MyClass::ListenThread' to create a pointer to member
什麼,我做錯了什麼?
您是否嘗試將'&MyClass :: ListenThread'作爲CreateThread的第三個參數? – imreal 2014-10-05 21:17:00
@imreal是的,我做到了。下一個錯誤是'錯誤C2664:'CreateThread':無法將參數3從'DWORD(__stdcall MyClass :: *)(LPVOID)'轉換爲'LPTHREAD_START_ROUTINE'' – maciekm 2014-10-05 21:21:51