重复标识符错误
我只是在 Lazarus 上进行编码,没有对 TForm
声明进行任何更改。然后我尝试测试我的应用程序,但在编译时出现此错误:
TomAct.lpr(11,43) Error: Duplicate identifier "TOMACT" TomAct.lpr(15,32) Error: Identifier not found "TForm1" TomAct.lpr(15,39) Error: Identifier not found "Form1" TomAct.lpr(19) Fatal: There were 3 errors compiling module, stopping
这是我的 *.lpr 文件的内容:
program TomAct;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms
{ you can add units after this }, TomAct;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
我需要做什么?
I was just coding on my Lazarus, without changing nothing on the TForm
declarations. Then I tried to test my application, but on the compilation I got this error:
TomAct.lpr(11,43) Error: Duplicate identifier "TOMACT" TomAct.lpr(15,32) Error: Identifier not found "TForm1" TomAct.lpr(15,39) Error: Identifier not found "Form1" TomAct.lpr(19) Fatal: There were 3 errors compiling module, stopping
And here is the content of my *.lpr file:
program TomAct;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms
{ you can add units after this }, TomAct;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
What I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,您有一个名为
TomAct
的单元,但您的项目也名为TomAct
。为您的项目或定义表单的单元选择不同的名称。第一个错误是关于重复标识符的,因为编译器认为您正在尝试“使用”项目本身,这是不允许的。它会发出错误消息并继续编译而不使用该单元。
未声明的标识符错误是第一个错误的副作用。由于该单元尚未被使用,编译器不知道其中声明的类型和变量。
Evidently, you have a unit named
TomAct
, but your project is also namedTomAct
. Pick a different name for your project or the unit where your form is defined.The first error, about the duplicate identifier, is because the compiler thinks you're trying to "use" the project itself, which isn't allowed. It issues an error message and continues compiling without using the unit.
The undeclared-identifier errors are side effects of the first error. Since the unit has not been used, the compiler doesn't know about the type and variable declared in it.