我不知道为什么这不起作用
#include <iostream>
#include <pthread.h>
using namespace std;
void *print_message(){
cout << "Threading\n";
}
int main() {
pthread_t t1;
pthread_create(&t1, NULL, &print_message, NULL);
cout << "Hello";
return 0;
}
错误:
[描述、资源、路径、位置、类型] 初始化参数 3
'int pthread_create(pthread_t*, const pthread_attr_t*, void*
(*)(void*), void*)' threading.cpp threading/src 第 24 行 C/C++
问题
您应该将线程 main 声明为:
void* print_message(void*) // takes one parameter, unnamed if you aren't using it
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)