Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!uc!cs.umn.edu!ux.acs!hopper From: hopper@ux.acs.umn.edu (hopper) Newsgroups: comp.std.c++ Subject: Re: Packing, Ordering, and Rearranging Message-ID: <2218@ux.acs.umn.edu> Date: 10 Sep 90 21:46:29 GMT References: <195@xstor.UUCP> <1233@lupine.NCD.COM> <1407@lupine.NCD.COM> Reply-To: hopper@ux.acs.umn.edu (Eric Hopper) Organization: Omnifarious Software Lines: 67 In article <1407@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: >In article roland@ai.mit.edu (Roland McGrath) writes: >+In article <1233@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: >+ >+ You can definitely specify what you want the exact layout of a struct to be >+ in C and have it be obeyed and have it be portable. People do it all the >+ time. Now if only this were possible in C++. :-( >+ >+Since this newsgroup is about the standard for C++, I'll assume you are talking >+about standard-conforming implementations of C as well. In this context, your >+assertion is patently false. Given the definition: >+ . . Rest of article deleted. > >Roland points out (quite correctly) that a standard conforming C compiler >is allowed to insert arbitrary amounts of space between. one member and >the next. > >Still, I my comment was *not* about just the subset of the aspects of >the behavior of C compilers which are "standard conforming" aspects. >Rather, my comment was meant to include general reality, and not just >"standard comformant" reality. > >The reality I'm speaking of is that given: . . . > >How many compilers do you know of that put arbitrary glops of empty space >in between struct members? This whole discussion is about making rules for structure packing more complex. I think that as long as the rules for a particular compiler are known, it's O.K. There are definate speed advantages to knowing the layout of your structure. I don't think the abstraction should get in the way of you making the most efficient possible code, no matter what the 'portability' issues, or whatever else are. Some people may argue that it is up to the compiler to make your code efficient. I would kindly direct them to some very nice languages that do this for you. Pascal, and FORTRAN are good examples. I personally don't like either of those languages because the compiler may be arbitrarily wrong (as far as efficiency is concerned), and you don't have enough control over the produced code to fix it. Making the structure packing rules too complex would bring you too far away from the machine you are programming, and make it impossible to preform some optimizations yourself. This is not what C, or C++ is about. Have fun, UUCP: rutgers!umn-cs!ux.acs.umn.edu!hopper (Eric Hopper) __ /) /**********************/ / ') // * I went insane to * / / ______ ____ o // __. __ o ____. . _ * preserve my sanity * (__/ / / / <_/ / <_<__//__(_/|_/ (_<_(_) (_/_/_)_ * for later. * Internet: /> * -- Ford Prefect * hopper@ux.acs.umn.edu /**********************/ -- -- Nils_McCarthy mtymp01@ux.acs.umn.edu rutgers!umn-cs!ux.acs.umn.edu!mtymp01 "The wonders of modern technology..." :-) :-) :-)