Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Packed structures (was: Absolute size of 'short') Message-ID: <6235@haddock.ima.isc.com> Date: 18 Aug 88 19:11:10 GMT References: <214@ISIDAPS5.UUCP> <9641@dartvax.Dartmouth.EDU> <62505@sun.uucp> <8186@cup.portal.com> Reply-To: karl@haddock.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 15 In article <8186@cup.portal.com> thad@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@haddock.isc.com), The Walking Lint