重复标识符错误

发布于 2024-09-12 18:03:39 字数 705 浏览 16 评论 0原文

我只是在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凌乱心跳 2024-09-19 18:03:39

显然,您有一个名为 TomAct 的单元,但您的项目也名为 TomAct。为您的项目或定义表单的单元选择不同的名称。

第一个错误是关于重复标识符的,因为编译器认为您正在尝试“使用”项目本身,这是不允许的。它会发出错误消息并继续编译而不使用该单元。

未声明的标识符错误是第一个错误的副作用。由于该单元尚未被使用,编译器不知道其中声明的类型和变量。

Evidently, you have a unit named TomAct, but your project is also named TomAct. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文