我在尝试使用 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
的内容,以便标准包含目录包含在自定义目录之前。
关于gcc - 错误: ‘::acos’ 尚未使用::acos 声明;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52322586/