Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site druxu.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!grkermit!masscomp!clyde!burl!ulysses!mhuxl!ihnp4!drutx!druxu!tll From: tll@druxu.UUCP Newsgroups: net.lang.c Subject: Re: C structure alignment Message-ID: <1051@druxu.UUCP> Date: Wed, 11-Apr-84 20:59:30 EST Article-I.D.: druxu.1051 Posted: Wed Apr 11 20:59:30 1984 Date-Received: Fri, 13-Apr-84 01:49:37 EST References: <122@ihnet.UUCP> Organization: AT&T Information Systems Laboratories, Denver Lines: 23 >From: tjr@ihnet.UUCP (Tom Roberts) > >It is NOT PORTABLE to assume the ordering of members within a structure, >nor to assume they are contiguous in memory. It's true that members may not be contiguous in memory, but (time for the bible-thumping quote from The C Reference Manual, p196) "Within a structure, the objects declared have addresses which increase as their declarations are read left-to-right." So the ordering is clearly defined. This feature is useful when you need to store a large number of structures that have differing amounts of data in them (for instance, in a circuit simulator, you might want a structure for each component -- early in the structure, you define what kind of component this is, and the rest of the structure is optimized for the particular component). A union could be used, but then you use the maximum amount of storage for each structure, which may be more than you have. Tom Laidig AT&T Information Systems Laboratories, Denver ...!ihnp4!druxu!tll