Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
- Subject: Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
- From: Dave Thorup <email@hidden>
- Date: Wed, 16 Nov 2005 09:57:21 -0500
On Nov 15, 2005, at 7:27 PM, Eric Albert wrote:
Nope. __LITTLE_ENDIAN__ is defined and set to 1 if you're building
for Intel, and __BIG_ENDIAN__ is defined and set to 1 if you're
building for PowerPC. Neither is defined on the other architecture.
OK, I think I was thinking of the TARGET_CPU_PPC, TARGET_CPU_PPC64 &
TARGET_CPU_X86 macros which are always defined, but only one of them
is ever defined as '1' and the rest '0'.
For what it's worth, we don't recommend using __LITTLE_ENDIAN__ or
__BIG_ENDIAN__ except in very rare cases. Use the swapping
functions in the system instead. They compile down to nothing when
you don't need to swap and keep you from having two copies of your
code.
Except that the swapping functions in the system are only defined on
Mac OS X, not on Windows. We've already got our own swapping
functions/macros that do the same thing. The only problem is that
instead of checking for big or little endian generically most of
these just use #ifdef WIN32 or #ifdef macintosh, etc.
So I'm changing the code to use the __LITTLE_ENDIAN__ and
__BIG_ENDIAN__ macros. Since neither of these are defined with the
Visual Studio compiler I need to implement the appropriate
definitions as well as do some error checking (for when none of them
are defined).
Thanks!
_____________________________
Dave Thorup
Software Engineer
email@hidden
http://www.kuwan.net
HyperSpell - Check spelling in Mac OS X from any application.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden