Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!mailrus!umich!samsung!dali.cs.montana.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Structure Member Padding Message-ID: <13332@smoke.BRL.MIL> Date: 10 Jul 90 02:37:50 GMT References: <1990Jul7.225141.12002@sq.sq.com> <13321@smoke.BRL.MIL> <10420@ogicse.ogc.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 18 In article <10420@ogicse.ogc.edu> daniels@ogicse.ogc.edu (Scott David Daniels) writes: - struct { short s; char a; }; - struct { short s; char a, b; }; - struct { short s; char a, b, c; }; -should all have the same head (that is, the addition of b and c should not -move where a belongs). But that has nothing to do with my point; in my example these would all have compatible layout, including the padding between s and a; I assumed that chars would not be packed into the same word as the short. - struct first { char a; short s; }; - struct second{ char a; short s; char b; }; - struct third { char a; char b; short s; }; -I would like to be able to use the same layout for third and second, ... But if shorts have specific alignment requirements, this is impossible. (At least, it would impose an unacceptable performance penalty.)