Intel porting tip

I now have most of my code working on the Intel Mac. Once again, I need to reiterate this bit of advice: Never assume Macs are Big Endian.

We already have a cross platform product that works on both Macs & PCs. Since it deals with binary data read from a file, it needs to handle byte ordering issues. In our code we used #ifdef __MAC__ for pieces of code that are sensitive to byte ordering. We also used #ifdef __MAC__ for a lot of other Mac-dependent stuff that had nothing to do with byte ordering. This was the cause of almost all of the problems I had with the port.

I’m sure a lot of other developers are doing the same thing. If you ever plan to port to Intel, go through your code and change any such tests to use #ifdef __LITTLE_ENDIAN__ or #ifdef __BIG_ENDIAN__ instead. Those things will bite you badly when you port to Intel. Better yet, use any of the byte order utilities whenever possible.

Comments are closed.