Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3902546
  • 博文数量: 534
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4800
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(534)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(253)

2006年(73)

分类: C/C++

2011-10-31 12:37:18

切记pthread_create返回值不是:小于0出错,0正确。

 RETURN VALUE
      Upon successful completion, pthread_create() returns zero. Otherwise,
      an error number is returned to indicate the error (the errno variable
      is not set).

以前比较傻总这样写:
   if (pthread_create(...) < 0)
   {
     /* error code .... */
   }

正确应该这样写比较合适:
   if (pthread_create(...) != 0)
   {
     /* error code ..., 最好输出errno, strerror(errno) */
   }

阅读(6453) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

limsco2011-11-01 22:41:14

额。。。。感觉与线程关系不大,这不只是泛型编程的细节吧!貌似