Path: utzoo!mnetor!uunet!husc6!mailrus!nrl-cmf!cmcl2!brl-adm!adm!MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU From: MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU Newsgroups: comp.lang.c Subject: Undelivered mail Message-ID: <12294@brl-adm.ARPA> Date: 12 Mar 88 11:07:04 GMT Sender: news@brl-adm.ARPA Lines: 52 Subject: Re: Pascal --> C question [Non-Deliverable: User does not exist or has never logged on] Reply-To: Info-C@BRL.ARPA Received: From UWAVM(MAILER) by ALASKA with Jnet id 7371 for SXJVK@ALASKA; Sat, 12 Mar 88 01:41 AST Received: by UWAVM (Mailer X1.25) id 5011; Sat, 12 Mar 88 02:41:06 PST Date: Fri, 11 Mar 88 01:41:57 GMT Reply-To: Info-C@BRL.ARPA Sender: Info-C List Comments: Warning -- original Sender: tag was netnews@psuvax1.cs.psu.EDU From: Scott Schwartz Subject: Re: Pascal --> C question Comments: To: info-c@BRL-SMOKE.arpa To: Vic Kapella 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"