Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1415810
  • 博文数量: 704
  • 博客积分: 10140
  • 博客等级: 上将
  • 技术积分: 6230
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-15 20:41
文章分类

全部博文(704)

文章存档

2013年(1)

2012年(16)

2011年(536)

2010年(151)

分类: C/C++

2011-06-17 16:36:18

今天在交叉编译一个程序的时候,发现了pthread_rwlock_t缺少定义~

检查了pthread.h文件,里边包含了pthreadtypes.h,并且有pthread_rwlock的操作函数:

...
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Functions for handling read-write locks.  */

/* Initialize read-write lock RWLOCK using attributes ATTR, or use
   the default values if later is NULL.  */

extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
                                __const pthread_rwlockattr_t *__restrict
                                __attr) __THROW __nonnull ((1));
...

看样子应该声明一个unix98的开关才可以,乱查一气,在:

看到了如下一段:


Single UNIX Specification (1998):

c89 -D _XOPEN_SOURCE=500 …
cc -std1 -D_XOPEN_SOURCE=500 …

然后使用这样的命令编译,果然就没有问题了。

iwmmxt_le-gcc  -Wall -W -o test test.c -pthread -D_XOPEN_SOURCE=500

或者:


iwmmxt_le-gcc  -Wall -W -o test test.c -pthread -D_GUN_SOURCE

记录一下,以免忘记。

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