[fpc-pascal]class methods in FPC version 1.9.0
dean
dezobec at tin.it
Thu Nov 13 10:20:43 CET 2003
When porting a Kylix/Delphi project to FPC (version 1.9.0 Linux) I've
encountered this small problem using class methods:
When I pass an object instance as parameter in class methods I have a sigsev
like in this example
program TestFail;
uses
SysUtils;
Type
TMyObject = Class
private
FNome: string;
published
Property Nome: string read FNome write FNome;
end;
TMyTestObject = class(TObject)
public
class function OutputParticularClass(AObj: TObject):string;
end;
var
obj: TMyObject;
class function TMyTestObject.OutputParticularClass(AObj: TObject): string;
begin
Result := AObj.ClassName;
Writeln(Result);
end;
begin
obj := TMyObject.Create;
TMyTestObject.OutputParticularClass(obj);
obj.Free;
end.
The above program compiles with no warnings in FPC, but at runtime it sigsevs.
I've run this in Kylix/Delphi and works as expected.
On the other hand I've seen that class methods work ok if the parameter passed
are integers for example
class function TMyTestObject.OutputNumber(aNumber: integer):string;
begin
Result := 'Number is ' + intToStr(aNumber);
Writeln(Result);
end;
begin
TMyTestObject.OutputNumber(12345);
end.
works ok in FPC
Am I doing something wrong or is a bug I've found?
Any ideas?
Ciao, Dean
More information about the fpc-pascal
mailing list