Duplicate Identifier Error lazarus / 13-General ---------------------------------------------------------------------- sandeep_c24 · 2007-12-24 07:37 Hi Why am I getting Duplicate Identifier Error for function SCTest? I am using Lazarus 0.9.24. Code: [Select] unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     procedure Button1Click(Sender: TObject);   private     { private declarations }     function SCTest : string;   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject);   function SCTest : string;   begin   end; begin end; function TForm1.SCTest: string; begin end; initialization   {$I unit1.lrs} end. Regards Sandeep ---------------------------------------------------------------------- Vincent Snijders · 2007-12-24 10:07 Because A. You use {$mode objfpc} and not {$mode delphi} or B. The nested function in TForm1.Button1Click has the same name as a private method of TForm1. ---------------------------------------------------------------------- sandeep_c24 · 2007-12-24 22:39 Even if I use Delphi mode it does not compile. I still get the same error. Does it mean FPC cannot handle this kind of stuff? This works in Delphi. Regards Sandeep ---------------------------------------------------------------------- Marc · 2007-12-27 10:33 in delphi mode it shoul be compatible with delphi. in objfpc mode the compiler is more strict. But if you gave us the exact line this error is on, then we know sure it is the SCTest procedure (it might be something else) ---------------------------------------------------------------------- sandeep_c24 · 2007-12-28 07:33 I get following errors Unit1.pas(32,19) Error: Duplicate identifier "SCTest" Unit1.pas(32,19) Hint: Identifier already defined in Unit1.pas at line 19 Unit1.pas(48) Fatal: There were 1 errors compiling module, stopping Regards Sandeep ---------------------------------------------------------------------- User137 · 2010-03-11 15:29 Quote from: Marc on December 27, 2007, 11:33:11 amin delphi mode it shoul be compatible with delphi. in objfpc mode the compiler is more strict. But if you gave us the exact line this error is on, then we know sure it is the SCTest procedure (it might be something else) Sorry for raising old topic but this is just stupid behavior from compiler's behalf, having to mode Delphi on all units. Code like this does not compile in fpc: Code: [Select]  TVertex = class     x,y,z: single;   public     constructor Create(x,y,z: single);     procedure Translate(x,y,z: single);   end;In object programming this would be no issue at all when using self.x etc. I mean.. it's in the very core of object oriented programming to be able to do things like this. Why call it objfpc if it actually has nothing to do with "object oriented", but something like old relic ---------------------------------------------------------------------- Leledumbo · 2010-03-12 00:57 QuoteIn object programming this would be no issue at all when using self.x etc.Indeed, that's why it's compilable in Delphi mode. However, the objfpc mode tends to be stricter so that the use of self is seldom (or never). The style you gave probably comes from C++/Java style OOP. Well, at least I was taught so.