🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1497

Re: Structure Member Padding

#1497
From: Karl Heuer
Date: Wed, 11 Jul 1990 21:57
15 lines
1321 bytes
In article <13321@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
>[Mark's] argument about struct member alignment seems correct, but it raises
>a problem with
>	struct { short s; char a, b, c; };
>on a word-addressed architecture, if short is made a half-word.  Note that
>your line of argument would lead to the conclusion that there can be no
>padding before the first char, but in such a situation a half-word of
>padding would be necessary.

I don't get it.  Why should a half-word of internal padding be necessary or
desirable?  Looks to me like the obvious implementation is to make it a
two-word struct, with the first word containing s and a and b, and the second
word containing c and three pad bytes.  What's the problem?

Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
Technical Details
Message-ID: <17069@haddock.ima.isc.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker!spdcc!ima!haddock!karl
References: <1929@xn.LL.MIT.EDU> <1990Jul6.152959.336@zoo.toronto.edu> <1990Jul7.225141.12002@sq.sq.com> <13321@smoke.BRL.MIL>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker!spdcc!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.std.c
Subject: Re: Structure Member Padding
Message-ID: <17069@haddock.ima.isc.com>
Date: 11 Jul 90 21:57:57 GMT
References: <1929@xn.LL.MIT.EDU> <1990Jul6.152959.336@zoo.toronto.edu> <1990Jul7.225141.12002@sq.sq.com> <13321@smoke.BRL.MIL>
Reply-To: karl@kelp.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Cambridge, MA 02138-5302
Lines: 15