[SOLVED] Strange error on interface in FPC 3.3.1 lazarus / 62-General ---------------------------------------------------------------------- gidesa · 2024-11-09 13:52 Hello, I have code as this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test;{$mode Delphi}uses    SysUtils;type  IMyInterface = interface    function    train(const samples: tobject; const labels: TArray): Boolean;    procedure   predict(const samples: tobject; var predictions: tobject);  end;   TMyClass = class(TInterfacedObject, IMyInterface)  private    k_nearest:      TObject;  public    constructor Create;    destructor  Destroy; override;    function    train(const samples: tobject; const labels: TArray): Boolean;    procedure   predict(const samples: tobject; var predictions: tobject);  end;     constructor TMyClass.Create;begin  inherited Create;end; destructor TMyClass.Destroy;begin  inherited Destroy;end; function TMyClass.train(const samples: tobject;                          const labels: TArray): Boolean;beginend; procedure TMyClass.predict(const samples: tobject;                          var predictions: tobject);beginend; //------------------------------------ ----------beginend.  Compiling with FPC 3.3.1, Laz 3.2, Windows 11, there is a strange error. Could be a bug? Code: [Select]Compile Project, Target: D:\GDS\pascal\ocvWrapper46\examples- Freepascal\DigitsRecognition\test.exe: Exit code 1, Errors: 2, Hints: 2 Hint: (11030) Start of reading config file D:\programmi\FPC3.3.1\fpc\bin\x86_64-win64\fpc.cfg Hint: (11031) End of reading config file D:\programmi\FPC3.3.1\fpc\bin\x86_64-win64\fpc.cfg Verbose: (11023) Free Pascal Compiler version 3.3.1-15402-ge67cccee37-dirty [2024/03/11] for x86_64 Verbose: (11023) Copyright (c) 1993-2024 by Florian Klaempfl and others Verbose: (1002) Target OS: Win64 for x64 Verbose: (3104) Compiling test.lpr test.lpr(35,19) Error: (3048) Function header doesn't match any method of this class "train(const TObject;const TArray$1$crcB6E8EE8F_crc39B5D60D):System.Boolean;" test.lpr(17,17) Error: (5088) Found declaration: train(const TObject;const TArray$1$crc713F463B_crc39B5D60D):System.Boolean; test.lpr(49,0) Verbose: (10026) There were 2 errors compiling module, stopping Verbose: (1018) Compilation aborted Verbose: (1018) D:\programmi\FPC3.3.1\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode ---------------------------------------------------------------------- Fibonacci · 2024-11-09 13:57 System.Integer = SmallInt hmmm objpas.pp is loaded later and overrides the "Integer" ---------------------------------------------------------------------- gidesa · 2024-11-09 14:09 Thank you, Fibonacci! That was the cause of error. There is System.Integer = smallint, and a different Integer = longint. This is originally Delphi 32bit code, where there is no distinction. ---------------------------------------------------------------------- cdbc · 2024-11-09 14:43 Hi Yup, I can confirm, that's the error. Putting the cursor in the 'train' declaration in interface of class and do [Ctrl+Shift+C] corrects it to compilation... even in 3.2.2 Regards Benny ---------------------------------------------------------------------- Fibonacci · 2024-11-09 17:01 Quote from: jamie on November 09, 2024, 05:57:14 pmHow long has that been like that? 20 years ---------------------------------------------------------------------- gidesa · 2024-11-09 17:08 The program was compiled in FPC for Win32 bit, and has {$Mode Delphi}. But Delphi 32 bit has System.Integer = Integer = longint. So also in Fpc, for mode Delphi, should be System.Integer = longint. It's not correct that it is smallint. ---------------------------------------------------------------------- Thaddy · 2024-11-09 18:48 Quote from: jamie on November 09, 2024, 07:23:52 pm[/b] accurate statement about FPC copying Delphi. We don't ; and that will stay that way. ---------------------------------------------------------------------- PascalDragon · 2024-11-11 18:50 Quote from: gidesa on November 09, 2024, 06:08:36 pmSo also in Fpc, for mode Delphi, should be System.Integer = longint. It's not correct that it is smallint. That simply is not possible (or at least a solution for this is not feasible). That is one of the things that are known incompatibilties between FPC and Delphi. ---------------------------------------------------------------------- jamie · 2024-11-11 22:58 So using a System.Integer gives you a 16 bit size. ? I know that it does because I've already have tested it, it's two bytes wide.