Undelivered mail

MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU
Sun Mar 13 07:05:56 AEST 1988


Subject:  Re: Pascal --> C question

[Non-Deliverable:  User does not exist or has never logged on]

Reply-To: Info-C at BRL.ARPA

Received: From UWAVM(MAILER) by ALASKA with Jnet id 8352
          for SXJVK at ALASKA; Sat, 12 Mar 88 11:33 AST
Received: by UWAVM (Mailer X1.25) id 5644; Sat, 12 Mar 88 12:33:27 PST
Date:         Fri, 11 Mar 88 11:32:41 GMT
Reply-To:     Info-C at BRL.ARPA
Sender:       Info-C List <INFO-C at NDSUVM1>
From:         "Richard A. O'Keefe" <ok at quintus.uucp>
Subject:      Re: Pascal --> C question
Comments: To: info-c at BRL-SMOKE.arpa
To:           Vic Kapella <SXJVK at ALASKA>

In article <3353 at psuvax1.psu.edu>, schwartz at gondor.cs.psu.edu (Scott Schwartz)
 writes:
> 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.

The trouble is that a Pascal compiler is absolutely free to ignore
'packed' entirely.  When you say
    var a: array [0.1023] of boolean;
you have no guarantee at all that the compiler won't use 1024 "words".
To quote the Berkeley Pascal manual page:
    "The keyword 'packed' is recognized but has no effect."
You would be lucky to find a Pascal compiler which will pack array
elements down to the bit level.  Byte level, yes.

The situation is better in C for two reasons.
(1) At least you can say
    char a[1024];
    and get nothing worse than byte packing.

(2) You can write the bit-extraction operations as macros, and use them
    over and over again on different arrays.

And of course there are those C compilers which have the "inline"
processor, so that you can have
    get_bit(array, index)
and    put_bit(array, index, value)
turned into your machine's instructions for bit access.  (Yay, Sun!)



More information about the Comp.lang.c mailing list