编译程序将BOOL CloseHandle(HANDLE hObject)理解为int __cdecl CloseHandle(void *),怎么回事?
我的程序如下:
#include <windows.h>
#include <process.h>
#include <stdio.h>
unsigned __stdcall ThreadProc(void *p)
{
printf("Thread execute!");
return 0;
}
int main()
{
unsigned tid;
unsigned long thd;
thd=_beginthreadex(NULL,0,ThreadProc,NULL,0,&tid);
if(NULL!=thd)
{
CloseHandle(thd);
}
WaitForSingleObject(thd,0);
return 0;
}
编译出错:
\multi_thread\main.cpp(18) : error C2664: 'CloseHandle' : cannot convert parameter 1 from 'unsigned long' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
\multi_thread\main.cpp(20) : error C2664: 'WaitForSingleObject' : cannot convert parameter 1 from 'unsigned long' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
CloseHandle的原型本来就是BOOL CloseHandle(HANDLE hObject);
编译程序却将它理解成:int __cdecl CloseHandle(void *)
这是怎么回事啊?