为什么会报math.h里面的错呢?
添加头文件#include<math.h>,使用fabs。编译时竟然报头math.h文件的错误。
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(495): error C2059: 语法错误:“(”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(495): error C2059: 语法错误:“-” 1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(495): error C2059: 语法错误:“)”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(496): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(496): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(499): error C2059: 语法错误:“(”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(499): error C2059: 语法错误:“-”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(499): error C2059: 语法错误:“)”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(500): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(500): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(547): error C2059: 语法错误:“(”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(547): error C2059: 语法错误:“-”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(547): error C2059: 语法错误:“)”
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(548): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>c:\program files\microsoft visual studio 10.0\vc\include\math.h(548): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
报错地方的代码
- C/C++ code
template<class _Ty> inline _Ty _Pow_int(_Ty _X, int _Y) {unsigned int _N; if (_Y >= 0) _N = (unsigned int)_Y; else _N = (unsigned int)(-_Y); for (_Ty _Z = _Ty(1); ; _X *= _X) {if ((_N & 1) != 0) _Z *= _X; if ((_N >>= 1) == 0) return (_Y < 0 ? _Ty(1) / _Z : _Z); }}inline double __CRTDECL abs(_In_ double _X) {return (fabs(_X)); }inline double __CRTDECL pow(_In_ double _X, _In_ int _Y) {return (_Pow_int(_X, _Y)); }从inline内联开始报错。
感觉不应该是系统这个头文件的问题。所以,又随便编了个小程序,发现正常。估计这报错应该和具体的程序有关。
那么到底会出错在哪些方面呢?从哪些方面入手找错误呢?
[解决办法]
少;号了吧!
[解决办法]
查看一下这句#include<math.h>之前你include 了什么文件 看是否有类声明少了分号之类的 ~~
[解决办法]
you missed the; )}
[解决办法]
我感觉也应该是少了分号
看一下你在#include<math.h>以前include的每一个文件追后一个需要;号的地方