2012-01-24 153 views
-2

我想编译一个需要cmath包含的函数的文件。我不相信我的代码本身会导致此错误,我怀疑配置(即使所有非包含代码都已注释,它仍然存在),但不知道发生了什么问题。我正在64位Windows主机上编译。除了添加masm build配置外,我不相信我已将任何编译设置更改为非默认设置,并且在禁用masm并将目标配置设置为32位后问题仍然存在。这里是我生成的输出:Visual C++编译器,编译错误stdlib.h

1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected 
1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected 
1>...\VStudio\VC\include\stdlib.h(467): error C2059: syntax error : ')' 
1>...\VStudio\VC\include\stdlib.h(468): error C2143: syntax error : missing ';' before '{' 
1>...\VStudio\VC\include\stdlib.h(468): error C2447: '{' : missing function header (old-style formal list?) 
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected 
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected 
1>...\VStudio\VC\include\stdlib.h(471): error C2059: syntax error : ')' 
1>...\VStudio\VC\include\stdlib.h(472): error C2143: syntax error : missing ';' before '{' 
1>...\VStudio\VC\include\stdlib.h(472): error C2447: '{' : missing function header (old-style formal list?) 

任何帮助将不胜感激。

编辑:

我发现了麻烦的一行。出乎我的意料,错误确实发生在代码,是从以前的版本继承了线的故障:

#define abs(a) ((a)<0? -(a):(a)) 

负责我的问题。

+2

请显示代码被包含在哪里。 –

+0

请发布您的代码。 – hmjd

+4

不仅如此,请向我们展示一个展示该问题的小型完整源文件。 –

回答

0

下一次,#include系统头在你自己的任何代码之前。这样,你的宏就不会混淆系统头文件,并导致你误入歧途。

+2

并提防'windows.h'和C++标准库之间的交互。始终用'#define NOMINMAX'来保护自己。 –