原文地址:gcc提示未知类型 pthread_spinlock_t
只要遇到的问题多,天天都能水博客
之前遇到一个问题 link,解决方案是改成 -std=gnu99
,这是前提
这次我用到了pthread_spinlock
,实现个简单的队列,我在 redis 的 makefile 中改了,但是编译还是提示
error: unknown type name ‘pthread_spinlock_t‘
pthread_spinlock_t head_lock;
经过我走读 makefile,发现 src/.make-settings
文件中有缓存之前的编译配置,导致make还是按照 -std=c99 编译的,手动改成 -std=gnu99
就好了。
注意
__GNU_SOURCE
和 ___USE_GNU
区别 https://blog.csdn.net/robertsong2004/article/details/52861078
_GNU_SOURCE
就有__USE_GNU
,一个内部用,一个外部用,指定编译选项gnu也会启用__GNU_SOURCE
和__USE_GNU
https://stackoverflow.com/questions/7296963/gnu-source-and-use-gnu_POSIX_C_SOURCE >= 200112L
http://man7.org/linux/man-pages/man3/pthread_spin_lock.3.html[转]gcc提示未知类型pthread_spinlock_t
原文:https://www.cnblogs.com/Forgenvueory/p/13219328.html