[fpc-pascal] Error: Can't take the address of constant expressions
patspiper
patspiper at gmail.com
Tue Sep 25 17:03:31 CEST 2012
Hi,
Despite
http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields,
shouldn't the following be legal? I tested under FPC 2.6.1 and 2.7.1.
TMyRecord = record
Data: pointer;
end;
TMyClass = class
private
FRef: TMyRecord;
public
property Ref: TMyRecord read FRef write FRef;
end;
var
MyClass1, MyClass2: TMyClass;
procedure test;
begin
Move(MyClass1.Ref.Data^, MyClass2.Ref.Data^, 1);
end;
The complete program is attached.
Thanks,
Stephano
-------------- next part --------------
program constaddresstest;
{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
type
TMyRecord = record
Data: pointer;
end;
TMyClass = class
private
FRef: TMyRecord;
public
property Ref: TMyRecord read FRef write FRef;
end;
var
MyClass1, MyClass2: TMyClass;
procedure test;
begin
Move(MyClass1.Ref.Data^, MyClass2.Ref.Data^, 1);
end;
begin
end.
More information about the fpc-pascal
mailing list