Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!sirius.ucs.adelaide.edu.au!sirius!jeremy From: jeremy@cs.ua.oz.au (Jeremy Webber) Newsgroups: comp.std.c++ Subject: Re: "packed" objects Message-ID: Date: 31 Jul 90 23:13:11 GMT References: <56159@microsoft.UUCP> <56165@microsoft.UUCP> <6785@netxcom.DHL.COM> Sender: news@ucs.adelaide.edu.au Organization: Digital Arts Film and Television Lines: 22 In-reply-to: ewiles@netxcom.DHL.COM's message of 31 Jul 90 17:55:14 GMT In article <6785@netxcom.DHL.COM> ewiles@netxcom.DHL.COM (Edwin Wiles) writes: A) You would not be guaranteed that a data file written by a given program on one machine, would be readable by the same program compiled on a different machine under a different implementation of C++. (Assuming that hardware and byte ordering are the same, the order of structure/class elements wouldn't necessarily be the same.) The ability for a compiler to re-order the elements of structures/unions is a useful optimization. I would argue that any code which writes structures to a data file is non-portable. If data is to be portable it should *always* be written element by element, preferably in ASCII. The programmer should never assume specific structure ordering, except in the case of bit field specifications, which can override the compiler's defaults. This is the sort of hackery which causes many C programs to fail! -- -- Jeremy Webber ACSnet: jeremy@chook.ua.oz Digital Arts Film and Television, Internet: jeremy@chook.ua.oz.au 60 Hutt St, Adelaide 5001, Voicenet: +61 8 223 2430 Australia Papernet: +61 8 272 2774 (FAX)