• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to conditionally compile by architecture?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to conditionally compile by architecture?


  • Subject: Re: How to conditionally compile by architecture?
  • From: Dan Korn <email@hidden>
  • Date: Thu, 18 Oct 2012 16:10:37 -0700
  • Acceptlanguage: en-US
  • Thread-topic: How to conditionally compile by architecture?

On Oct 18, 2012, at 5:21 PM, Stephen Kay <email@hidden> wrote:

> So, since the #defines about Byte Order don't really answer my question,
> then let's go back to it: How *do you* conditionally compile based on CPU
> Type?

#ifdef __ppc__
// PowerPC
#elif defined(__i386__) || defined(__x86_64__)
// Intel
#else
// something else
#endif

http://blog.onesadcookie.com/2007/07/useful-gcc-macros.html
http://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time
http://sourceforge.net/p/predef/wiki/Architectures/
https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/64bitPorting/MakingCode64-BitClean/MakingCode64-BitClean.html

But I agree with Andrew; you should have very few reasons to use these for Mac-specific code, since most of the APIs you would be calling in C/C++ shouldn't vary much between PowerPC and Intel.  You're mainly going to be concerned with endianness.   (And of course, PowerPC is pretty much a dead end anyway, as is Carbon.)

Mac SDK changes are determined by the MAC_OS_X_VERSION_MIN_REQUIRED and MAC_OS_X_VERSION_MAX_ALLOWED macros in AvailabilityMacros.h.  (These, in turn, depend on SDK settings in your project, which you can read about elsewhere.)

You may also want to take a look at macros such as TARGET_API_MAC_OSX in ConditionalMacros.h.

Dan


 _______________________________________________
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

  • Follow-Ups:
    • Re: How to conditionally compile by architecture?
      • From: Stephen Kay <email@hidden>
References: 
 >Re: How to conditionally compile by architecture? (From: Stephen Kay <email@hidden>)

  • Prev by Date: Re: Xcode 3.2.6 on 10.8?
  • Next by Date: Re: Xcode 3.2.6 on 10.8?
  • Previous by thread: Re: How to conditionally compile by architecture?
  • Next by thread: Re: How to conditionally compile by architecture?
  • Index(es):
    • Date
    • Thread