Article View: comp.std.c++
Article #395Re: Packing, Ordering, and Rearranging
From: Tim Iverson
Date: Mon, 20 Aug 1990 22:59
Date: Mon, 20 Aug 1990 22:59
22 lines
1598 bytes
1598 bytes
In article <1233@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: >In article <195@xstor.UUCP> iverson@xstor.UUCP (Tim Iverson) writes: ><If the language had constructs for specifying such things as packing and ><ordering (bit, word, etc.), it could deal transparently with structures ><created outside of its own venue and should result in code that is ><both cleaner and more portable. > >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. I don't know what kind of C you're using, but in both K&R and ANSI C, the structs are definitely not WYSIWIG - the compiler is allowed to insert any number bytes between fields for the sake of padding. This makes the struct wholely non-portable; i.e., two programs with the same struct are not guaranteed to interpret the data in the struct in the same way. BTW, almost all of the compiler vendors realize this and provide some way to "pack" a struct (e.g. #pragma pack()). >Ron Guilmette - Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg - Tim Iverson uunet!xstor!iverson
Technical Details
Message-ID:
<198@xstor.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!xstor!iversonReferences:
<1030@lupine.NCD.COM> <56637@microsoft.UUCP> <195@xstor.UUCP> <1233@lupine.NCD.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!xstor!iverson From: iverson@xstor.UUCP (Tim Iverson) Newsgroups: comp.std.c++ Subject: Re: Packing, Ordering, and Rearranging Message-ID: <198@xstor.UUCP> Date: 20 Aug 90 22:59:29 GMT References: <1030@lupine.NCD.COM> <56637@microsoft.UUCP> <195@xstor.UUCP> <1233@lupine.NCD.COM> Reply-To: iverson@xstor.UUCP (Tim Iverson) Organization: Storage Dimensions, Inc. Lines: 22