Forum > General
[SOLVED] Strange error on interface in FPC 3.3.1
gidesa:
Hello,
I have code as this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program test;{$mode Delphi}uses SysUtils;type IMyInterface = interface function train(const samples: tobject; const labels: TArray<Integer>): 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<Integer>): 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<System.Integer>): 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: ---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
--- End code ---
Fibonacci:
System.Integer = SmallInt
hmmm
objpas.pp is loaded later and overrides the "Integer"
gidesa:
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:
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:
--- Quote from: jamie on November 09, 2024, 05:57:14 pm ---How long has that been like that?
--- End quote ---
20 years
Navigation
[0] Message Index
[#] Next page