From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: HELP ! need to insert value in array !!
Date: 1997/07/04
Date: 1997-07-04T00:00:00+00:00 [thread overview]
Message-ID: <5pht85$d4o$1@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: dewar.867589873@merv
dewar@merv.cs.nyu.edu (Robert Dewar) writes:
>What would one expect on a PDP10 with 5 characters per word and an unused
>bit left over, or does the ANSI C standard require 36 bits/character on
>this machine?
UCHAR_MAX must be at least 255. All objects in C must have a size that is
a multiple of the size of a byte, and since we'd expect 36-bit int and
float on a PDP-11, that means the size of a "byte" has to be a factor of
36 that is greater than or equal to 8. That means the possible sizes for
a char in a PDP-10 implementation of C are
9 bits (4 per word)
18 bits (2 per word)
36 bits (1 per word)
I've actually used the Snyder C compiler for the PDP-10, but I can't
remember what it did. I'm pretty sure it wasn't 9 bits per char.
Note that 5 ASCII characters per word was a software convention; for C
programs to inter-operate with other code, you'd need to convert, but then
for things like opening files you'd need to convert to _six bit_ characters.
>suppose that type T is a struct with a double field and an int field.
>The size of this struct would be 12 bytes, but its alignment requirement
>is 8, so it would not be possible to laout the array b without alignment
>gaps???
The point is that the size of an _isolated_ variable of type T must be
exactly the same as the size of an _array element_ of type T. Yes, there
would be padding in your type T, but it would be in _all_ variables of
that type, not just ones in an array. (You could think of every object in
C being an element of a one-element array, and with respect to pointer
arithmetic, that model would not mislead you.)
--
Four policemen playing jazz on an up escalator in the railway station.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.
next prev parent reply other threads:[~1997-07-04 0:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <33A9C27C.22F7@post4.tele.dk>
[not found] ` <5oci49$97g@crl.crl.com>
[not found] ` <866920621snz@genesis.demon.co.uk>
1997-06-27 0:00 ` HELP ! need to insert value in array !! Ralph Silverman
1997-06-28 0:00 ` Lawrence Kirby
[not found] ` <dewar.867554609@merv>
1997-06-29 0:00 ` Mike Rubenstein
1997-06-29 0:00 ` Robert Dewar
1997-06-29 0:00 ` Mike Rubenstein
1997-06-29 0:00 ` Robert Dewar
1997-06-29 0:00 ` Mike Rubenstein
1997-06-30 0:00 ` Ed Hook
1997-07-04 0:00 ` Richard A. O'Keefe
1997-07-07 0:00 ` Clive D.W. Feather
1997-07-01 0:00 ` Al Bowers
1997-07-01 0:00 ` Richard Kenner
1997-07-01 0:00 ` Robert Dewar
1997-07-02 0:00 ` Christian Froeschlin
1997-07-02 0:00 ` Robert Dewar
1997-07-04 0:00 ` Richard A. O'Keefe [this message]
1997-07-04 0:00 ` Robert Dewar
1997-07-04 0:00 ` Mike Rubenstein
1997-07-05 0:00 ` Robert Dewar
1997-07-05 0:00 ` Larry Kilgallen
1997-07-05 0:00 ` Mike Rubenstein
1997-07-05 0:00 ` Mike Rubenstein
1997-07-10 0:00 ` Alan Bowler
1997-07-07 0:00 ` Shmuel (Seymour J.) Metz
1997-07-07 0:00 ` Mark H. Wood
1997-07-09 0:00 ` Robert Dewar
1997-07-10 0:00 ` Lawrence Kirby
1997-07-08 0:00 ` Richard Kenner
1997-06-30 0:00 ` Samuel T. Harris
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox