Is there any definitive info how packed types _should_ work in GPC. The following program:
Program BitSz;
Var R: packed record aa: packed record c: Boolean; end; a: Boolean; b: 1..3; end (* R *);
begin writeln ( ' R.aa:', BitSizeOf ( R.aa ), ' R.aa.c:', BitSizeOf ( R.aa.c), ' R.a:', BitSizeOf ( R.a ), ' R.b:', BitSizeOf ( R.b ), ' R:', BitSizeOf ( R )); end.
writes: R.aa:8 R.aa.c:1 R.a:1 R.b:2 R:16
which shows that packed records inside packed records currently (with gpc 2.1) take the same space as outside.
Waldek Hebisch wrote:
Is there any definitive info how packed types _should_ work in GPC.
No ultimate info. According to the standard, `packed' doesn't even have to do anything.
The following program:
Program BitSz;
Var R: packed record aa: packed record c: Boolean; end; a: Boolean; b: 1..3; end (* R *);
begin writeln ( ' R.aa:', BitSizeOf ( R.aa ), ' R.aa.c:', BitSizeOf ( R.aa.c), ' R.a:', BitSizeOf ( R.a ), ' R.b:', BitSizeOf ( R.b ), ' R:', BitSizeOf ( R )); end.
writes: R.aa:8 R.aa.c:1 R.a:1 R.b:2 R:16
which shows that packed records inside packed records currently (with gpc 2.1) take the same space as outside.
I think it might be rather difficult to implement the "even more packed" behaviour, because then, while laying out the inner record, you'd have to know the current bit offset of the outer one. (Not impossible, sure, just more tricky.)
I'm not sure if this effort is worth the benefit. Of course, if you'd like to implement it, just try it ...
Frank