Undelivered mail

MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU
Sat Mar 12 21:07:04 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 7371
          for SXJVK at 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 at BRL.ARPA
Sender:       Info-C List <INFO-C at NDSUVM1>
Comments:     Warning -- original Sender: tag was netnews at psuvax1.cs.psu.EDU
From:         Scott Schwartz <schwartz at gondor.cs.psu.EDU>
Subject:      Re: Pascal --> C question
Comments: To: info-c at BRL-SMOKE.arpa
To:           Vic Kapella <SXJVK at ALASKA>

swarbric at 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 at gondor.cs.psu.edu      | tail, yet it will be proof against
                                        | defeat.  -- Sun Tzu, "The Art of War"



More information about the Comp.lang.c mailing list