Endianness problems when writing certain objects

Bob Arning arning at charm.net
Tue Jan 23 15:55:10 UTC 2001

On Tue, 23 Jan 2001 16:35:16 +0100 "Wouter Gazendam" <wouter at cosmocows.com> wrote:
>I've noticed some weird behaviour when writing objects to a stream. I guess
>it's related to the PC/Mac endianness problem. Try sending
>FlashCharacterMorph from a PC to a Mac and vice versa (using 'save morph in
>The problem occurred with at least the following classes: ShortPointArray,
>1. What is the current mechanism in Squeak to make sure PC and Mac Stream
>are byte compatible?
>2. What about a mechanism to make sure littleEndian (PC) machines always
>write their Objects in bigEndian form?
>Any help, explanation on the reading/writing Objects to a Stream would be


Some of this should be handled already - SoundBuffer>>writeOn:, e.g., has some code to do this. Looking at senders of #endianness will reveal a few other places where this is dealt with. An alternative approach would be to ensure that the stream indicated the endianess under which it was written so that any swapping would be done by the reading image, if needed. This would spare the little-endian machines from needing to convert when writing and when reading little-endian streams. The only conversion then would be when a stream went from one universe to the other.


More information about the Squeak-dev mailing list