【发布时间】:2014-01-23 02:26:56
【问题描述】:
我开始使用 Pthreads 进行编程。我使用 Dev-C++ 并将库链接到项目。简单的程序可以编译,但它不起作用。下面我附上了代码。有谁知道问题出在哪里?
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <windows.h>
void *func (void* x){
printf("(%s)",'Hi. It's thread number 1');
return 1;
}
int main() {
pthread_t thread;
int x=1;
pthread_create(&thread, NULL, func, &x);
pthread_join(thread,1);
return 0;
}
【问题讨论】:
-
你遇到了什么错误?
-
定义:不起作用
-
再看看
printf的电话。 -
为什么不起作用?您的预期行为是什么?另外,不要使用
Dev-C++,它已经过时了。最后,除非您明确下载了 Windows 的 pthread 库,否则 Windows 本身并不支持 posix 线程。 -
你写“它不工作”是什么意思?该程序做了什么,您期望它做什么?