【转】‘PTHREAD_MUTEX_RECURSIVE’未声明的解决方法

原文地址: http://blog.csdn.net/alextanghao/archive/2009/03/06/3963810.aspx
但是用gcc 就出现 ‘PTHREAD_MUTEX_RECURSIVE’未声明(在此函数内第一次使用) 这样的提示,pthread.h已经包含了,问题出在编译参数上面。

g++ recursion.c -orecursion -lpthread

gcc recursion.c -orecursion -lpthread -D_GNU_SOURCE


gcc 多了一个 -D_GNU_SOURCE 选项

** 对于Linux下的信号量/读写锁文件进行编译,需要在编译选项中指明-D_GNU_SOURCE

gcc -D_GNU_SOURCE hello.c
means the compiler will use the GNU standard of compilation, the superset of all
other standards under GNU C libraries.

猜你喜欢

转载自dazhilao.iteye.com/blog/791899
今日推荐