Packed records

Frank Heckenbach frank at g-n-u.de
Thu Aug 29 19:33:58 CEST 2002


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

-- 
Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html




More information about the Gpc mailing list