Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!batcomputer!pyramid!decwrl!cookie.dec.com!devine From: devine@cookie.dec.com (Bob Devine) Newsgroups: comp.lang.c Subject: Re: what C needs -- packed structures Message-ID: <8801071842.AA04669@decwrl.dec.com> Date: 7 Jan 88 18:42:24 GMT Organization: Digital Equipment Corporation Lines: 27 Path: decwrl!labrea!rutgers!cmcl2!brl-adm!brl-smoke!gwyn Subject: Re: what C needs I wrote: >When writing code that requires control of alignment or location, > [...I want a way to pack a structure] Doug Gwyn wrote: > If you're under the impression that a simple, efficient mechanism > exists or could feasibly be made to exist for "rolling in" raw binary > data obtained from another system, you're sadly mistaken. No, I didn't want a full-blown XDR or presentation layer type of function. What I described was smaller. I stemmed from an experience where two vendor's compilers where used on the same architecture but with different layouts of data. Frustrating! A different argument for providing packed/unpacked structures is simply to allow the programmer to choose between access speed or smaller data segment. As an example of prior art, Microsoft C has a compile time flag for this. Granted, not all structures would be packed the same way or even could be packed. Some architectures allow ints to be only integer aligned (pyramid, I believe) while others all ints to be char aligned (vax). Consider this suggestion in light of the C philosophy or letting the programmer decide.