🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #222

Re: "packed" objects (Oops! Forgot something!)

#222
From: Michael Meissner
Date: Wed, 01 Aug 1990 23:13
33 lines
2269 bytes
In article <MCGRATH.90Aug1122802@helen.Berkeley.EDU>
mcgrath@helen.Berkeley.EDU (Roland McGrath) writes:

| The only arguments I have heard against arbitrary reordering of structures are
| that it is incompatible with C, and that it makes writing structures to files
| less portable.
| 
| Being incompatible with C is not something I consider a valid reason for not
| doing something.  That's why we have `extern "C"'.  A structure declared within
| `extern "C"' would, of course, obey C's conventions and not get reordered.
| 
| Writing structures to files as they appear in memory is not portable anyway.
| Even given the same machine (and thus the same sizes for the basic types and
| the same byte and word orders), different compilers (or even different compiler
| options) may use different padding in structures.
| 
| Are there any other arguments against allowing arbitrary reordering of
| structures?

Hmm, don't you care about compatibility with things like system calls?
I imagine the grief people would get if the stat structure got
rearranged because some OS jock added a byte field at the end of the
structure?  Yes, extern "C" can be used, but it just means that there
are even more things to worry about getting right.

Also, it would seem to me that reordering things across class
boundaries is a really bad idea -- then subclassing and virtual
functions would have no chance of working.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA

Do apple growers tell their kids money doesn't grow on bushes?
Technical Details
Message-ID: <MEISSNER.90Aug1191316@osf.osf.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!paperboy!meissner
References: <56159@microsoft.UUCP> <56165@microsoft.UUCP> <6785@netxcom.DHL.COM> <6786@netxcom.DHL.COM> <GSTEIN.90Jul31194438@goober.oracle.com> <MCGRATH.90Aug1122802@helen.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!paperboy!meissner
From: meissner@osf.org (Michael Meissner)
Newsgroups: comp.std.c++
Subject: Re: "packed" objects (Oops! Forgot something!)
Message-ID: <MEISSNER.90Aug1191316@osf.osf.org>
Date: 1 Aug 90 23:13:16 GMT
References: <56159@microsoft.UUCP> <56165@microsoft.UUCP>
 <6785@netxcom.DHL.COM> <6786@netxcom.DHL.COM>
 <GSTEIN.90Jul31194438@goober.oracle.com>
 <MCGRATH.90Aug1122802@helen.Berkeley.EDU>
Sender: news@OSF.ORG
Organization: Open Software Foundation
Lines: 33
In-reply-to: mcgrath@helen.Berkeley.EDU's message of 1 Aug 90 19:28:02 GMT