Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Porting from Linux to MacOS



> > My C++ code is supposedly open platform, standard, etc...
> > What are the things I should know in order to port my
> program to the MacOS?
>
> The number one issue is byte swapping. Far too many people
> assume that 16
> and 32 bit values can be read from a file directly into int's
> and short's.
> This is no longer the case. The bytes are reversed on PowerPC/680x0
> processors. (Floats and doubles too).

Just to be very clear, bits within the bytes themselves aren't reversed, but
the byte order within multi-byte types is reversed. The PowerPC, having the
minority market share, has single-instruction solutions to this problem;
look into Endian.h in the 'Headers, and the __lhbrx and __lwbrx CodeWarrior
macros. I would actually say that the bytes are reversed on Intel
processors, since Intel's bits go (8 - 1)(16 - 9) in disregard of the Arabic
numeral convention of MSB first.

Other than that, the trickiest part is the system-specific calls that any
real app has to make. There are several tricks for handling these, usually
involving wrapping them in some platform-neutral function calls.

Happy coding!

Eugene Foss


References: 
 >Re: Porting from Linux to MacOS (From: Burger <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.