Re: Best practice for OS version and SDK conditionals?
Re: Best practice for OS version and SDK conditionals?
- Subject: Re: Best practice for OS version and SDK conditionals?
- From: Chris Espinosa <email@hidden>
- Date: Thu, 3 Apr 2008 10:42:26 -0700
On Apr 3, 2008, at 9:50 AM, William Bates wrote: I'm updating and trying to put away some code until the next OS revision, and I'm trying to figure out not _how_ - I know this - but the _best_ place to set compiler variables such as MAC_OS_X_VERSION_MAX_ALLOWED; I'm also trying to work out some of the interactions of these sorts of compiler conditionals with precompiled headers. A lot of these source files are in areas such as CoreAudio that have changed a lot from OS 10.3 to OS 10.5. My end goal is to get them as self-documented as possible....
Here are some questions:
(1) Should I #include <AvailabilityMacros.h> in my Prefix.pch?
Generally unnecessary. Almost any high-level framework you use is going to end up #including or #importing this. It doesn't hurt, but it will hardly make any difference. (2) If yes, should I use precede it with #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 etc., type statements, or not?
Those get set by the compiler implicitly, very early in the process, depending on the values passed in -mmac-os-x-min-version, so no, you do not need to set them. The right thing to do is to set the build settings usefully for your target, and let Xcode, the compiler, and AvailabilityMacros take care of the rest. (3) When compiling, how can I just dump (using #warning or similar) the current setting(s) of compile time variables like MACOSX_DEPLOYMENT_TARGET?
Temporarily add -dM to Other C Flags and preprocess any source file. You'll get a dump of all macro definitions in effect for that file in the current target. (4) What syntax works on compiler conditionals? For example, (MACOSX_DEPLOYMENT_TARGET > MAC_OS_X_VERSION_10_4) works but >= does not.
The C Preprocessor
I'm happy to hear opinions on practices that are probably matters of style and taste.
It depends on what you're really trying to do: - #ifdef out lines of code on a per-OS basis - compile (or not compile) entire source files
I'm using Xcode 3.1 beta (dare I speak its name?)
It hardly matters in this context, Xcode has behaved this way since 2.1 or earlier.
|
_______________________________________________
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