Re: How to conditionally compile by architecture?
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