【发布时间】:2020-03-21 03:30:48
【问题描述】:
我将gcc升级到5.4,除了math.h似乎还可以
当我写一个 hello.cpp 如下:
#include<math.h>
int main(){return 0;}
然后我用 gcc 5.4、g++ 5.4 编译上面的 cpp
g++ hello.cpp
发生错误
In file included from /usr/include/math.h:70:0,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:16: error: expected constructor, destructor, or type conversion before ‘(’ token
__MATHCALL_VEC (cos,, (_Mdouble_ __x));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:65:16: error: expected constructor, destructor, or type conversion before ‘(’ token
__MATHCALL_VEC (sin,, (_Mdouble_ __x));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:81:22: error: ‘sincos’ has not been declared
__MATHDECL_VEC (void,sincos,,
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:81:29: error: expected identifier before ‘,’ token
__MATHDECL_VEC (void,sincos,,
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:82:3: error: expected identifier before ‘(’ token
当我降级到 gcc 4.8、4.9 时,仍然会出现这个问题
【问题讨论】:
-
gcc 5.4 已经很老了。当前版本是 9.3。你能更新到更新的东西吗?您的
gcc和libc6-dev软件包都是最新的吗? -
@KeithThompson gcc5.4 在我的其他服务中运行良好,我使用
apt-get install gcc-5.4,然后使用apt-get install build-essential,所以 gcc 和 libc6-dev 是最新的 -
我还尝试从 4.8、4.9 到 5.4 删除所有 gcc 和 g++ 版本和 apt-get install,但它没有帮助。我的意思是 gcc 在没有 #include
的情况下运行良好。所以我不知道该怎么办,是我在升级gcc时忘记安装的东西吗? -
Google 搜索“mathcalls.h”“预期构造函数”表明其他人遇到了这个问题。在前几个结果中我没有看到解决方案。如果你的耐心超过我的耐心,也许你会找到一些东西。
-
@KeithThompson 所以一个可能的解决方案是重新安装我的系统?天哪,太糟糕了
标签: c++11 ubuntu-16.04 glibc gcc5