在MinGW环境下必须使用pthread库编译多线程程序吗?我在TrueStudio中看到集成MinGW中的头文件声明了_beginthreadex函数。但程序运行出现异常。我不知道我是否使用了 _ beginthreadex 函数。
//process.h
/* Thread initiation and termination functions.
*
* NOTE: Apparently _endthread() calls CloseHandle() on the handle of the
* thread, creating a potential for race conditions, if you are not careful.
* Basically, you MUST ensure that NOTHING attempts to do ANYTHING with the
* thread handle after the thread calls _endthread(), or returns from the
* thread function.
*
* NOTE: No old names for these functions. Use the underscore.
*/
_CRTIMP __cdecl __MINGW_NOTHROW
unsigned long _beginthread (void (*)(void *), unsigned, void *);
_CRTIMP __cdecl __MINGW_NOTHROW void _endthread (void);
#ifdef __MSVCRT__
_CRTIMP __cdecl __MINGW_NOTHROW unsigned long _beginthreadex
(void *, unsigned, unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
_CRTIMP __cdecl __MINGW_NOTHROW void _endthreadex (unsigned);
#endif
更新:以上信息是否表明MSVC编译器需要支持_beginthreadex函数,而不是_beginthread函数?