🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9573

Re: C structs & A question about octet

#9573
From: Eric Lund
Date: Thu, 06 Nov 1986 20:10
34 lines
2239 bytes
"The C Programming Language", Kernighan and Ritchie, p. 196: "Each
non-field member of a structure begins on an addressing boundary
appropriate to its type; therefore, there may be unnamed holes in a
structure."

Kernighan and Ritchie say nothing of how big or small the unnamed holes
may be.  I've used one C compiler that byte aligned chars in structs
until it encountered a short, then used even byte alignment until it
encountered a long, and then aligned everything on four byte
boundaries.  There is nothing in the quoted sentence that prevents
anyone from writing a code generator that always aligns every non-field
member on a 4K boundary.

Mayhaps you can use fields for some of your needs, but "Field members
are packed into machine integers; they do not straddle words."
(p. 196), and "... implementations are not required to support any but
integer fields.  Moreover, even int fields may be considered to be
unsigned." (p. 197)  To increase your confidence in predicting the
behavior of the C compiler, p. 212 starts out "Purely hardware issues
like word size...".

(Ever tried sending a raw structure over a heterogeneous network
without benefit of RPC?  Back when you were young and foolish and
didn't know that VAXen and SUNs have different byte orders?  And you
thought that structs were all the same?  You have my sympathies!)


You could name bit types of differing lengths VIII, XVI, and XXXII,
but I don't think that that's what you intend.

					Eric the DBA

Disclaimer: any opinions found herein are mine.  Please return them;
no questions asked.
Technical Details
Message-ID: <3406@sdcrdcf.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!eric
References: <2904@rsch.WISC.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!eric
From: eric@sdcrdcf.UUCP (Eric Lund)
Newsgroups: net.lang.c,comp.lang.c
Subject: Re: C structs & A question about octet
Message-ID: <3406@sdcrdcf.UUCP>
Date: Thu, 6-Nov-86 15:10:48 EST
Article-I.D.: sdcrdcf.3406
Posted: Thu Nov  6 15:10:48 1986
Date-Received: Fri, 7-Nov-86 23:02:25 EST
References: <2904@rsch.WISC.EDU>
Reply-To: eric@sdcrdcf.UUCP (Eric Lund)
Distribution: net
Organization: System Development Corporation R&D, Santa Monica
Lines: 34
Keywords: Alignment, structs, word sizes