我在尝试使用CLion构建cpp项目时遇到此错误。这是错误消息:
/usr/include/c++/5/cmath:102:11: error: ‘::acos’ has not been declared
using ::acos;
^
/usr/include/c++/5/cmath:121:11: error: ‘::asin’ has not been declared
using ::asin;
^
/usr/include/c++/5/cmath:140:11: error: ‘::atan’ has not been declared
using ::atan;
^
/usr/include/c++/5/cmath:159:11: error: ‘::atan2’ has not been declared
using ::atan2;
^
/usr/include/c++/5/cmath:180:11: error: ‘::ceil’ has not been declared
using ::ceil;
^
/usr/include/c++/5/cmath:199:11: error: ‘::cos’ has not been declared
using ::cos;
...
在项目中,有一个名为~/someproject/src/math.h
的自定义头文件。将~/someproject/src/math.h
文件名更改为非冲突名称(如math1.h
(并相应地更新其引用))可解决错误。
有没有人知道另一个不需要更改名称的解决方案?
有几种解决方案:
#include "../src/math.h
#include <src/math.h>
-I/usr/include
之类的包含路径,以便在自定义目录之前包含标准包含目录。