C math.h编译错误:应为声明说明符或'';在'之前;(';

C math.h编译错误:应为声明说明符或'';在'之前;(';,c,C,我正在尝试编译一个相当大的项目。几个文件包括math.h。我得到的编译错误是: "In file included from math.h:71:0, mathcalls.h:310:1: error: expected declaration specifiers or '...' before '(' token" 我知道我的数学标题没有被更改,它们包含我刚刚编写的“hello math world”程序,因此我不确定问题出在哪里。mathcalls.h文件中给出错误的具体行是 /* R

我正在尝试编译一个相当大的项目。几个文件包括math.h。我得到的编译错误是:

"In file included from math.h:71:0,

mathcalls.h:310:1: error: expected declaration specifiers or '...' before '(' token"
我知道我的数学标题没有被更改,它们包含我刚刚编写的“hello math world”程序,因此我不确定问题出在哪里。mathcalls.h文件中给出错误的具体行是

/* Round X to nearest integral value, rounding halfway cases away from
   zero.  */
__MATHCALLX (round,, (_Mdouble_ __x), (__const__));

有什么线索表明问题出在这里吗?

您在包含
之前定义了

#define round(x) trunc((x+0.5))
#include <math.h>

您是否确保所有标题只被适当的ifdef包含一次?您确定它包含在文件范围内吗?我从特定文件中删除了#include,它现在正在编译。它包含在其他文件中。我仍然不明白问题是什么。Math.h有自己的#ifndef来防止它被多次包含。A至少它现在正在编译。如果您先定义
log2
,或者定义mathcalls.h中使用的一系列其他内容,则会发生相同类型的错误。这只会发生在gcc上,而不会发生在其他编译器(如Visual Studio)上。
In file included from /usr/include/math.h:71:0,
                 from a.c:2:
/usr/include/bits/mathcalls.h:310:1: error: expected declaration specifiers or '...' before '(' token