根据以下记录,该代码独立存在,很好:
pax> cat qq.c
typedef struct {
int id;
int department;
} employee;
int main (int argc, char *argv[]) {
int i;
employee job[3]; ////////////////error
for (i=0;i<3;i++) {
//do something
}
return 0;
}
pax> gcc -o qq qq.c
pax>
. 您可能需要检查的一些事项是:
- 有什么
#define
类似employee
or的东西job
吗?
- 你确定
employee
这两个地方的拼写一样吗?
- 你确定你拥有所有你声称拥有的分号吗?
- 您的代码中是否有任何“有趣”的字符(那些看起来不可见但仍将您的输入流填充到编译器的字符)?
A good first start would be to comment out the errant line and see if you get the error on the following line. That should narrow it down to either that line (no error) or a previous line (still have error).
You can see the entire file in hex mode (looking for funny characters) if you do something like:
od -xcb myfile.c
(under Linux - Windows I'm not sure though, if you have gvim
, you can convert it to hex with a menu item).