Layout of Structs

jac@paul.rutgers.edu (J. A. Chandross)
28 May 89 02:06:27 GMT

          From comp.compilers

Related articles
Layout of Structs jac@paul.rutgers.edu (1989-05-28)
Re: Layout of Structs henry@zoo.toronto.edu (1989-05-31)
Re: Layout of Structs jac@paul.rutgers.edu (1989-06-02)
Re: Layout of Structs aglew@mcdurb.Urbana.Gould.COM (1989-06-04)
| List of all articles for this month |
From: jac@paul.rutgers.edu (J. A. Chandross)
Newsgroups: comp.compilers
Keywords: symbol tables, offsets, psects, real-time monitor
Date: 28 May 89 02:06:27 GMT
References: <3979@ima.ima.isc.com>
Distribution: na
Organization: Rutgers Univ., New Brunswick, N.J.

stein@pixelpump.osc.edu (Rick 'Transputer' Stein)
> I have some questions about how a compiler constructs a symbol table.
> [questions on structure layout deleted]


Our erstwhile moderator replies:
> C compilers have the right to lay out structures any way they see fit,
> unless the ANSI committee changed the rules.


I quote, without permission, from The Bible, page 196, First Edition:


"Within a structure, the objects declared have addresses which increase
as their declarations are read lef-to-right. Each non-field member of
a structure begins on an addressing boundry appropriate to its type;
therefore, there may be unnamed holes in a structure. Field members
are packed into machine integers; they do not straddle words. A field
which does not fit into the space remaining in a word is put into the
next word....."


It is a Good Thing [tm] that structures are laid out in this way. As
a hardware type, I often need to write device drivers. Being able to
impose a structure onto a hardware memory map is a very useful thing,
indeed.


Jonathan A. Chandross
Internet: jac@paul.rutgers.edu
UUCP: rutgers!paul.rutgers.edu!jac
[I hope I'm not the erstwhile moderator yet, but stand corrected. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.