Re: How to conditionally compile by architecture?
Re: How to conditionally compile by architecture?
- Subject: Re: How to conditionally compile by architecture?
- From: Nick Zitzmann <email@hidden>
- Date: Thu, 18 Oct 2012 12:08:49 -0600
On Oct 18, 2012, at 11:38 AM, Stephen Kay <email@hidden> wrote:
> I've finally gotten this old CodeWarrior PPC app I'm porting to the point of
> being fully imported into Xcode 2.5, and building successfully on PPC.
>
> I've now moved to an Intel machine to start working on making it run on
> Intel.
>
> Assuming I want to maintain backwards compatibility with PPC (for the
> moment, anyway...), how do you identify the architecture in order to do
> conditional compiling for one or the other? What's the define? I.e.:
>
> #ifdef INTEL_ARCHITECTURE
> // do byte-swapping
> #endif
>
> Or alternately,
>
> #ifdef PPC_ARCHITECTURE
> // do old way
> #endif
You don't want to do this, because if the OS gets ported to, say, SuperH or MIPS, then you'll have additional work to accomplish. Use __BIG_ENDIAN__ and __LITTLE_ENDIAN__ instead if all you care about is compiling conditionally based on the endian-ness of the CPU.
But why not instead use the swap-big-to-host functions that are in Foundation and CoreFoundation? That way you won't have to use #ifdefs at all if all you need to do is byte-swapping based on architecture.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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