Packed structures (was: Absolute size of 'short')
Lee Carver
lee at ssc-vax.UUCP
Thu Aug 18 01:55:03 AEST 1988
In article ... davidsen at crdos1.UUCP (bill davidsen) writes:
> I would really like to see a "packed struct," also. This would be a
> struct packed on byte boundaries without fill, no matter *how bad* the
> code was to use them.
In article <1258 at ficc.UUCP> peter at ficc.UUCP (Peter da Silva) writes:
> ... how about ..
> packed struct { int a:1; int b; int c:17; } argh;
Why should packing be constrained to byte boundarys. Why not any
'type' boundary? Sure, some elements might not have addresses, but
the code is probably machine/application dependent any. Invariably
packed structures are.
So how about
packed [ type-specifier ] [ structure-specifier ]
The elements of the structure-specifier are aligned to
type-specifier boundaries. Maybe default to byte if an empty type-
specifier is used? Allow the type specifer to be anything, even
other structures.
Then, some proposals might be represented as:
packed short struct { char a; long b; char c; } blix;
and for wierdness
packed structure blix struct { float b; char *d;} blax;
More information about the Comp.lang.c
mailing list