Path: utzoo!mnetor!uunet!husc6!bbn!gatech!psuvax1!gondor.cs.psu.edu!schwartz From: schwartz@gondor.cs.psu.edu (Scott Schwartz) Newsgroups: comp.lang.c Subject: Re: Pascal --> C question Message-ID: <3353@psuvax1.psu.edu> Date: 11 Mar 88 01:41:57 GMT References: <650001@hpcilzb.HP.COM> <4940001@hpiacla.HP.COM> <3352@psuvax1.psu.edu> <4766@sigi.Colorado.EDU> Sender: netnews@psuvax1.psu.edu Reply-To: schwartz@gondor.cs.psu.edu (Scott Schwartz) Organization: Penn State University Lines: 34 swarbric@tramp.Colorado.EDU (Frank Swarbrick) writes: >: >:Except that the useful ones are never that easy. One of my favorites: >: bitstring: packed array[0..1023] of boolean; >:In C you have to do bit-fiddling by hand to get the same effect. >: >typedef char bool; >bool bitstring[1024]; > >Or does the "packed" thing in Pascal have some special meaning? I never could >figure out what the difference between a packed array and a regular array was. The "packed" thing has a special meaning. I can't quote you from the ANSI or ISO standards offhand, but the idea is that the compiler is supposed to arrange that the packed structure takes up a minimal amount of space (probably subject to some alignment restrictions). So in the example I gave each boolean would take up one bit, and there would be 1024 of them, the whole array taking up 128 bytes. Unpacked, each boolean would take up one, two, or maybe four (depending on how unlucky you are) bytes. In (I can't believe I'm about to type this, but...) the hypothetical "D" language it would be nice to be able to say typedef bool bit; bool bitstring[1024]; but, alas.... -- Scott Schwartz | Your array may be without head or schwartz@gondor.cs.psu.edu | tail, yet it will be proof against | defeat. -- Sun Tzu, "The Art of War"