我在类的成员函数里面有如下语句创建线程:
hthread = CreateThread(NULL,NULL,thread_pro,NULL,0,&threadID);
其中hthread,thread_pro,threadID全部是全局变量或者函数
其中thread_pro函数定义为:
DWORD WINAPI thread_pro()
{
if (WaitForSingleObject(hEvent,0) != WAIT_TIMEOUT)
{
pcap_breakloop(adhandle);
return (DWORD)-1;
}
pcap_loop(adhandle,0,packet_handler,(unsigned char*)dumper);
return 0;
}
-------------------
但是创建线程是出现如下错误,好像是说create线程函数的第三个参数类型有问题~
请问是什么原因,谢谢!错误信息如下:
-------------------
error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void)' to 'unsigned long (__stdcall *)(void *)'
None of the functions with this name in scope match the target type
hthread = CreateThread(NULL,NULL,thread_pro,NULL,0,&threadID);
其中hthread,thread_pro,threadID全部是全局变量或者函数
其中thread_pro函数定义为:
DWORD WINAPI thread_pro()
{
if (WaitForSingleObject(hEvent,0) != WAIT_TIMEOUT)
{
pcap_breakloop(adhandle);
return (DWORD)-1;
}
pcap_loop(adhandle,0,packet_handler,(unsigned char*)dumper);
return 0;
}
-------------------
但是创建线程是出现如下错误,好像是说create线程函数的第三个参数类型有问题~
请问是什么原因,谢谢!错误信息如下:
-------------------
error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void)' to 'unsigned long (__stdcall *)(void *)'
None of the functions with this name in scope match the target type
楼主你的CreateThread函数的第三个参数错误,void类型不能够转化成unsinged long ,你在函数线程函数体的时候其中的函数没有说明,以下函数形式才是正确的!
DWORD WINAPI ThreadProc(
LPVOID lpParameter // thread data
if (WaitForSingleObject(hEvent,0) != WAIT_TIMEOUT)
{
pcap_breakloop(adhandle);
return (DWORD)-1;
}
pcap_loop(adhandle,0,packet_handler,(unsigned char*)dumper);
return 0;
);
DWORD WINAPI thread_pro(void * para)