二进制“<<”: 没有找到接受“pthread_t”类型的右操作数的运算符(或没有可接受的转换)
z_k_h 2017-04-11 05:11:26 #include "MutiThread.h"
#include <pthread.h>
#include <iostream>
using namespace std;
#define THREAD_NUM 5
class Hello{
public:
static void *hello(void *args){
int i = *((int*) args);
cout << "hello in" << i << endl;
return ((void*)0);
}
};
int main(){
pthread_t id[THREAD_NUM];
for(int i=0;i<THREAD_NUM;i++){
int ret = pthread_create(&id[i],NULL,Hello::hello,(void*) &i);
pthread_join(id[i],NULL);
if(ret==0){
cout << pthread_self() <<"线程执行成功" << endl;
}else{
cout << ret << endl;
}
}
pthread_exit(NULL);
}
编译报错的地方:cout << pthread_self() <<"线程执行成功" << endl;
vs2008执行打印线程的线程号,为什么会报标题的错误啊,编译时候报的