wallace000
wallace000

Reputation: 21

why does it compile error when i only #include<math.h>

i upgrade gcc to 5.4, it seems to be ok except math.h

when i write a hello.cpp like the following:

#include<math.h>
int main(){return 0;}

then i compile the above cpp with gcc 5.4, g++ 5.4

g++ hello.cpp

errors happen

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

when i downgrade to gcc 4.8, 4.9, this problem still happens

Upvotes: 1

Views: 1648

Answers (2)

wallace000
wallace000

Reputation: 21

I found a solution:

apt-get install linux-libc-dev

Upvotes: 1

user3236841
user3236841

Reputation: 1258

This question is not reproducuble for me.

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

Compiles without error. And runs:

Valgrind reports no errors upon running.

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

Something is wrong with the poster's installation. Also, as others have said, upgrade gcc.

Upvotes: 1

Related Questions