gcc - 错误: ‘::acos’ 尚未使用::acos 声明;

标签 gcc clion math.h

我在尝试使用 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 的内容,以便标准包含目录包含在自定义目录之前。

引用:https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

关于gcc - 错误: ‘::acos’ 尚未使用::acos 声明;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52322586/

相关文章:

c - 我对代码块相当陌生。我在这个错误上花了太多时间。有人能指出我在这段代码中的错误吗

c++ - 将 "No known conversion"作为参数传递时来自 const 的 "this"

Clion 无法解析 __int128_t 但编译器另有说明

c - GCC 4.6 中奇怪的诊断编译指示行为

c++ - 调试时的 CLion 标准输入

c++ - 重构:在 CLion 中移动 (F6) - 为什么它会这样工作?

c - c 程序中的错误 : ld returned 1 exit status

c - 如何在没有 math.h 的情况下编写一个简单的对数函数?

c++ - 在 gcc 上没有警告的情况下确定类方法的返回类型

c++ - gcc:带有 Wextra 和成员初始化的 weffc++