Eclipse goto标签不在C中工作。

时间:2023-01-13 11:22:21

I am using the Eclipse CDT and I have a goto label and a FILE definition after it and when I compile the project it gives me the error: Expression expected before FILE.

我使用的是Eclipse CDT,在它之后,我有一个goto标签和一个文件定义,当我编译这个项目时,它给我一个错误:在文件之前的表达式。

Thanks in advance, Mr. Man

先生,先谢谢你。

EDIT:

编辑:

Ok, so this is what I get from the command line:

这就是我从命令行得到的结果

iOS.c: In function ‘main’:
iOS.c:45: error: expected expression before ‘FILE’
iOS.c:49: error: ‘preFile’ undeclared (first use in this function)
iOS.c:49: error: (Each undeclared identifier is reported only once
iOS.c:49: error: for each function it appears in.)`

And this is what code throws the error:

这就是代码抛出错误的地方:

fileExists:

FILE *preFile = fopen("prefix.txt","r");

1 个解决方案

#1


3  

As you're coding in C, you need to declare the variable at the beginning of the function:

当你用C编码时,你需要在函数开始时声明变量:

void foo()
{
  FILE* preFile;

  // some code

  fileExists:
  preFile = fopen("prefix.txt","r");
}

#1


3  

As you're coding in C, you need to declare the variable at the beginning of the function:

当你用C编码时,你需要在函数开始时声明变量:

void foo()
{
  FILE* preFile;

  // some code

  fileExists:
  preFile = fopen("prefix.txt","r");
}