1

我将 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 时,这个问题仍然存在

4

2 回答 2

1

我找到了一个解决方案:

apt-get install linux-libc-dev
于 2020-03-22T03:41:59.857 回答
1

这个问题对我来说是不可重现的。

g++ hello.cpp -ansi -Wall -pedantic

编译没有错误。并运行:

Valgrind 在运行时没有报告错误。

==100412== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

海报的安装有问题。另外,正如其他人所说,升级 gcc。

于 2020-03-21T04:50:42.440 回答