pthread 오류 어떻게 해야할까요?
CreamyGirl
질문 제목 : pthread 오류 어떻게 해야할까요?질문 요약 :dev c++로 돌리고 있는데요. pthread.h : no such file or directory라고 뜹니다.
어떻게 해야 컴파일이 가능한가요?이 소스를 리눅스로 돌릴 예정입니다. 제발ㅠ_ㅠ!!!!!!!! 도와주십쇼.
질문 내용 :
#include unistd.h
#include stdio.h
#include stdlib.h
#include string.h
#include pthread.h
#include string.h
#define max_str 255
struct thread_arg{
pthread_t pt_id;
inttime;
char str[max_str];
};
void *messagealarm(void *);
int main(){
struct thread_arg thr_arg;
while(1){
scanf(%d, &thr_arg.time);
if(thr_arg.time == -1) break;
fgets(thr_arg.str, max_str, stdin);
if(pthread_create(&thr_arg.pt_id, null, messagealarm, (void *)&thr_arg)){
fprintf(stdout, [main] fail: pthread_create()\n);
return 0;
}
}
return 0;
}
void *messagealarm(void *arg)
{
struct thread_arg *th_arg = (struct thread_arg *)arg;
struct thread_arg data = *th_arg;
pthread_detach(pthread_self());
sleep(data.time);
fputs(data.str, stdout);
pthread_exit((void *)null);
}