Packed structures (was: Absolute size of 'short')

Karl Heuer karl at haddock.ima.isc.com
Fri Aug 19 05:11:10 AEST 1988


In article <8186 at cup.portal.com> thad at cup.portal.com writes:
>Constructs such as the following do NOT function "properly" with most
>compilers:
>     struct OneBitElement { int  foo : 1; };
>     struct MyDataBlock { struct OneBitElement bletch[32]; };

As a consequence of the sizeof() rules, I don't think it could function
"properly" on *any* C compiler.  (I think the sizeof(char)==1 rule should have
been deprecated, but X3J11 says it's too late to change it now.)

Your "bit" extensions seem useful, but unfortunately they don't fit in very
well with the rest of the language.  In particular, the automatic mapping of
arrays to pointers makes it hard to handle bit arrays.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list