hThread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)GetPacketThread,(LPVOID)NULL,(DWORD)0,&m_dwThreadID);当我将GetPacketThread 这个函数改成类成员函数时,就会出错!为什么会怎样,该如何改才可以!
出错信息:
error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)'None of the functions with this name in scope match the target type
我是不是应该把哪个改成afxBeginThread函数呢?LPTHREAD_START_ROUTINE这个是做什么用的?
出错信息:
error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)'None of the functions with this name in scope match the target type
我是不是应该把哪个改成afxBeginThread函数呢?LPTHREAD_START_ROUTINE这个是做什么用的?
你在吗?
好象是类型不对,可如何改呢?
DWORD WINAPI GetPacketThread(LPVOID lpParameter);
另外,MFC中创建线程最好用AfxBeginThread,MFC有些内部的数据结构要维护。如果用AfxBeginThread的话,把函数原型写成这样:
UINT GetPacketThread(LPVOID pParam );
AfxBeginThread((AFX_THREADPROC)GetPacketThread,NULL);
谢谢webber84(糕鱼昏)
LPTHREAD_START_ROUTINE这个是什么意思呢?
typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(
LPVOID lpThreadParameter
);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
volatile int nTemp
中的volatile 是干什么用的?
象这些变量前的这些关键字,可以去那里找到解释!
The volatile keyword is a modifier used in the declaration of variables. Use of this keyword specifies that the value the variable contains may change asynchronously, and, therefore, the compiler should not attempt to perform optimizations with it.
----from MSDN