这段程序,为什么编译不能通过?
#include "stdafx.h"#include "conio.h"
#include "stdlib.h"
#include "string.h"
#include "windows.h"
#include "stdio.h"
#include <time.h>
#include <process.h>
unsigned Counter;
unsigned __stdcall SecondThreadFunc( void* pArguments )
{ printf( "In second thread...\n" );
while ( Counter < 1000000 )
Counter++;
_endthreadex( 0 );
return 0;}
void main()
{ HANDLE hThread;
unsigned threadID;
printf( "Creating second thread...\n" ); // Create the second thread.
hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID );
// Wait until second thread terminates. If you comment out the line
// below, Counter will not be correct because the thread has not
// terminated, and Counter most likely has not been incremented to
// 1000000 yet.
WaitForSingleObject( hThread, INFINITE );
printf( "Counter should be 1000000; it is-> %d\n", Counter ); // Destroy the thread object.
CloseHandle( hThread );
}
为什么编译不能通过?提示D:\App_PC\12\12.cpp(17) : error C2065: '_endthreadex' : undeclared identifier
D:\App_PC\12\12.cpp(25) : error C2065: '_beginthreadex' : undeclared identifier
Error executing cl.exe.
12.exe - 2 error(s), 0 warning(s)
可是我不是已经包含process.h了么?怎么回事?