🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1501

Re: Size of structure containing char fields

#1501
From: Henry Spencer
Date: Wed, 18 Jul 1990 15:25
15 lines
1100 bytes
In article <1030@lzaz.ATT.COM> bds@lzaz.ATT.COM (Bruce Szablak) writes:
>Given a structure that contains only char fields (possibly unsigned):
>
>	struct example1 { char a, b, c; };
>
>is ANSI restrictive enough [;-)] to force sizeof(example1) to be 3?
>Is anyone aware of existing compilers for which this wouldn't be true?

ANSI more or less leaves the question open.  Machines on which char
pointers are strange will almost certainly pad the structure to a word
boundary so they can use "normal" pointer format for `struct example1 *'.
Some compilers on more ordinary machines may do likewise.  Some won't.
-- 
NFS:  all the nice semantics of MSDOS, | Henry Spencer at U of Toronto Zoology
and its performance and security too.  |  henry@zoo.toronto.edu   utzoo!henry
Technical Details
Message-ID: <1990Jul18.152500.4591@zoo.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!henry
References: <1030@lzaz.ATT.COM>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Size of structure containing char fields
Message-ID: <1990Jul18.152500.4591@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1030@lzaz.ATT.COM>
Date: Wed, 18 Jul 90 15:25:00 GMT