error: syntax error before "pthread_rwlock_t"

写好的代码,在另外一个平台编译,出错,犹如上提示,两个环境的编译器版本不一样, 搜到解决办法如下 两台机器,一台编译正常,另一台报错: error: syntax error before "pthread_rwlock_t" 仔细查看发现编译正常的机器gcc版本是gcc version 4.1.2,报错的gcc版本是gcc version 3.4.6 继续搜索,发现pthread_rwlock_t 在pthreadtypes.h文件中有定义: ... #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)); ... 编译时加上参数 -D_XOPEN_SOURCE=500 或者 在文件中define __USE_UNIX98 或者__USE_XOPEN2K 500 转自:http://hi.baidu.com/algol_dream/blog/item/6190b1c2810a5d40b319a89d.html
posted @ 2011-07-19 16:18  夏大王  阅读(1133)  评论(0编辑  收藏  举报