猎鹰刺客
2016-08-04 07:40Ubuntu14.04 gcc编译出错: undeclared
编译出错:‘EXIT_FALLURE’ undeclared (first use in this function) exit(EXIT_FALLURE);
源码如下:
#include
#include
#include
#include
void *thread_function(void *arg);
int main()
{
int res;
pthread_t a_thread;
void *thread_result;
res = pthread_create(&a_thread,NULL,thread_function,NULL);
if(res != 0)
{
perror("Pthread bulid faile!\n");
exit(EXIT_FAILURE);
}
sleep(3);
printf("Cancel patread...\n");
res = pthread_cancel(a_thread);
if(res != 0)
{
perror("Cancel pathread faile!\n");
exit(EXIT_FAILURE);
}
sleep(3);
printf("Cancel patread...\n");
res = pthread_cancel(a_thread);
if(res != 0)
{
perror("Cancel pathread faile!\n");
exit (EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
void *thread_function(void *arg)
{
int i,res;
res = pthread_setcancelstste(PTHREAD_CANCEL_ENABLE,NULL);
if(res != 0)
{
perror("Pthread is faile!\n");
exit(EXIT_FALLURE);
}
printf("Pthread is running!\n");
for(i=0;i<10;i++)
{
printf("Pthread is running %d...\n");
sleep(1);
}
pthread_exit(0);
}
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- Ubuntu 14.04:无法找到包php7.0-zip
- ubuntu
- php
- 1个回答
- Ios推送通知PHP脚本不适用于Ubuntu 14.04
- ios
- ubuntu
- php
- 1个回答
- 在ubuntu14.04上使用apache安装PHP5.3
- apache
- php
- 2个回答
- 发布请求不工作Drupal和Ubuntu 14.04
- apache
- drupal
- php
- 2个回答
- 请教如何在14.04lts的ubuntu下安装3.10.0的CMAKE?感激不尽!
- cmake
- ubuntu
- 3个回答