Error with static "direct field" properties
Original Reporter info from Mantis: Brainenjii
-
Reporter name:
Original Reporter info from Mantis: Brainenjii
- Reporter name:
Description:
I meet some troubles with declare properties with direct field access.
Some example:
program Project1;
{mode objfpc}{
H+}
{$static on}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
{$R *.res}
Type
{ TMyClass }
TMyClass = Class
Private
fMyInteger: Integer; Static;
fMyString: ShortString; Static;
Function GetInternalInteger: Integer;
Function GetInternalString: String;
Public
Property MyString: ShortString Read fMyString;
Property MyInteger: Integer Read fMyInteger;
Property InternalString: String Read GetInternalString;
Property InternalInteger: Integer Read GetInternalInteger;
Constructor Create;
End;
{ TMyClass }
Function TMyClass.GetInternalInteger: Integer;
Begin
Result := fMyInteger;
end;
Function TMyClass.GetInternalString: String;
Begin
Result := fMyString;
end;
Constructor TMyClass.Create;
Begin
fMyInteger := 100;
fMyString := 'hello world';
End;
begin
With TMyClass.Create Do
Begin
WriteLn(MyInteger); // <- Junk
WriteLn(MyString); // <- Empty string
WriteLn(InternalInteger); // <- 100
WriteLn(InternalString); // <- Hello world
Free;
End;
end.
Mantis conversion info:
- Mantis ID: 20124
- OS: linux
- Platform: i386
- Version: 2.4.4
- Monitored by: » @martin_frb (Martin Friebe)