Path: 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 In article <1233@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: >In article <195@xstor.UUCP> iverson@xstor.UUCP (Tim Iverson) 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. 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