[fpc-devel] composed record with private/public => documented behaviour?
Martin Frb
lazarus at mfriebe.de
Wed Oct 28 07:47:07 CET 2026
The fields of the embedded record become available in the outer record.
What visibility do they get (I can and have tested, and results make
sense / but I want to know, if that is the designed / documented behaviour)
- fields are in the outer section? E.g T3.a is public, because the outer
is public
- fields are according to the inner? E.g. T2.c is public, because the
inner is public
- fields are the lowest of both? E.g. 2 access rules must both be passed
to access
Also what if the outer record is NOT advanced? and does not have
visibility? (that I have not tested yet)
unit Unit2; {$mode ObjFPC}{$H+}
{$ModeSwitch advancedrecords} {$ModeSwitch recordcomposition}
interface
type
T1 = record
private a,b: integer;
public c,d: integer;
end;
unit Unit1; {$mode ObjFPC}
{$ModeSwitch advancedrecords} {$ModeSwitch recordcomposition}
interface
uses unit2;
type
T2 = record
private
contains T1;
end;
T3 = record
public
contains T1;
end;
More information about the fpc-devel
mailing list