复制一些用于工作增强线程的数据,我在下面实现了以下代码。我收到错误 C:\dev\default threads_threads.cpp|18|error: invalid conversion from 'void ( )(void )' to 'unsigned int ( attribute (( stdcall )) )(void )' [-fpermissive]|
但是...评论的行是推荐的,评论解释了我得到的错误。
事实证明,强烈推荐 _beginThreadEx,但在网络上的文档记录很差(如教程中)
#include <iostream>
#include <process.h>
void myThread(void *data)
{
//C:\dev\default threads\_threads.cpp|6|error: invalid conversion from 'int*' to 'int' [-fpermissive]|
//int x = static_cast<int*>(data);
int *x = (int*)data;
std::cout << "Hellow World! " << x;
}
int main()
{
int x = 10;
_beginthreadex(NULL, 0, myThread, &x, 0, NULL);
while(true);
}