Search code examples
duplicateslazarusidentifier

Duplicate Identifier Error


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?


Solution

  • 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.