当前位置:   article > 正文

linux clock_t 头文件,Linux开发:error: ‘clockid_t’ has not been declared

osg error: ‘::clock’ has not been declared

今天在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了!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/926711
推荐阅读
相关标签
  

闽ICP备14008679号