赞
踩
今天在Linux下进行编程开发,需要一个时间类的模块,就写了一个名为time的类,用于项目的时间模块。
名为:
time.h
time.c
结果编译时发现报出:
/usr/include/pthread.h:239:34: error: ‘clockid_t’ has not been declared │~
239 | clockid_t __clockid, │~
| ^~~~~~~~~ │~
/usr/include/pthread.h:750:9: error: ‘clockid_t’ has not been declared │~
750 | clockid_t __clockid, │~
| ^~~~~~~~~ │~
/usr/include/pthread.h:896:12: error: ‘clockid_t’ has not been declared │~
896 | clockid_t __clockid, │~
| ^~~~~~~~~ │~
/usr/include/pthread.h:918:12: error: ‘clockid_t’ has not been declared │~
918 | clockid_t __clockid, │~
| ^~~~~~~~~
经排查发现:
1.我的项目中使用pthread多线程库
2.pthread库使用time库
3.我的项目工程下与c/c++的time库重名了
3.我使用-I 命令将头文件目录优先级设成我工程项目下的include头文件目录了
总结:
编译器在编译器pthread时,因为上面设置了优先级目录,编译器将我的time.h给了pthread,而非c/c++库里的time.h
所以我把项目中的time换了个名字就编译OK了!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。