On Mon, 1 Aug 2022, Skybuck Flying via fpc-pascal wrote:
}
{$mode objfpc}{$H+}
You need additionally a modeswitch for advanced records, or properties in
records will not work:
{$modeswitch advancedrecords}
// UNION example
case integer of
0 : ( mData : int64 );
1 : ( mByte : packed array[0..7] of byte );
// DOES COMPILE
end;
TDataExample2 = record
mField : integer;
// UNION example
case integer of
0 : ( mData : int64 );
1 : ( mByte : packed array[0..7] of byte );
// !!! DOES NOT COMPILE, PROBLEM !!!
property Field : integer read mField write mField;
end;
The variant part of a record must always come last.
The property should be moved to before the 'case' :
TDataExample2 = record
mField : integer;
property Field : integer read mField write mField;
case integer of
0 : ( mData : int64 );
1 : ( mByte : packed array[0..7] of byte );
end;
This compiles when I tried.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal