|
源码:
#include <stdio.h>
#include <pthread.h>
void *pp(void *arg)
{
while (1) {
printf("%s\n", (char *)arg);
sleep(2);
}
return NULL;
}
main()
{
pthread_t pid;
pthread_create(&pid, NULL, pp, "hello world");
while (1) {
printf("I am main thread\n");
sleep(1);
}
}
用 gcc test.c -o tt -lpthread
程序可以正常运行.
但是我用g++ test.c -o tt -lpthread出来错误. sleep undeclared....
请问为什么,怎么能解决? |
|