错误:':: acos'尚未使用:: acos声明;

问题描述 投票:0回答:1

我在尝试使用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(并相应地更新其引用))可解决错误。

有没有人知道另一个不需要更改名称的解决方案?

gcc clion math.h
1个回答
0
投票

有几种解决方案:

  • 使用亲属包括例如#include "../src/math.h
  • 使用补丁组件,例如#include <src/math.h>
  • 修复包含类似-I/usr/include之类的包含路径,以便在自定义目录之前包含标准包含目录。

参考:https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

© www.soinside.com 2019 - 2024. All rights reserved.