On Mar 15, 2007, at 9:10 AM, Sean McBride wrote: On 2007-03-14 20:33, David Alger said:
On Mar 14, 2007, at 11:31 AM, Sean McBride wrote:
On 3/13/07 9:32 PM, David Alger said:
I have looked all over for this, but can't seem to find a way. I want Xcode to emit an error when I try using functions that are not available in 10.3.9 and earlier while at the same time compiling against the 10.4u SDK. Is there a way to do this.
I have tried setting these defines...
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3 #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
You are not supposed to #define these in your code.
That isn't true, read AvailabilityMacros.h.
I have. Where does it say you should #define them?
It doesn't specifically say to define them. The pre-processor define directive is just the way to do it. If you look in the Xcode user guide you'll find that the compiler doesn't specify MAC_OS_X_VERSION_MAX_ALLOWED. The compiler does specify MAC_OS_X_VERSION_MIN_REQUIRED based on the deployment target. But, the docs say that changing the SDK includes a different set of headers (of course). It also says that it is set in the AvailabilityMacros.h file specific to the SDK in question.
"One of the files in the new search path is $(SDKROOT)/usr/include/AvailabilityMacros.h, which is the principal header for driving weak linking support. This header file sets the preprocessor macro MAC_OS_X_VERSION_MAX_ALLOWED to a constant that is equivalent to the version represented by that SDK (for example, 1028 for Mac OS X v10.2.8)." You quoted yourself a few posts ago:
"This header enables a developer to specify build time constraints on what Mac OS X versions the resulting application will be run. There are two bounds a developer can specify: MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_MAX_ALLOWED"
They are careful to use the word "specify" not "#define". You specify them in the Xcode GUI by choosing the target SDK and the deployment target (SDKROOT and MACOSX_DEPLOYMENT_TARGET). Xcode then defines them before AvailabilityMacros.h is included, and most umbrella frameworks (Carbon, Cocoa) include it early on.
See above. That is also where they are given there default values if not previously defined. If I don't define them, I don't get warnings. If I define them as such I get deprecation warnings.
I pre-compiled a source file with a function only available in 10.4 called in it. This is what I get, "void Foo() __attribute__ ((unavailable));" This, as far as I'm concerned, should throw an error like the header says it should. Unless I'm doing something wrong that is.
I think this is one of those things that so simple it's complicated (like byte swapping). I get it messed up a lot and so have made a note about it all in a 'notes' file I keep. These are the words of one or more people from the list, sorry I forget who:
---- The SDK (SDKROOT) you choose specifies the *maximum* version of the OS that you want to *use features from*.
Yes, but it sets it via a #define in AvailabilityMacros.h. There is another build setting, the deployment target (MACOSX_DEPLOYMENT_TARGET) that specifies the *minimum* version of the OS that you want to *run on*.
MAC_OS_X_VERSION_MIN_REQUIRED set from MACOSX_DEPLOYMENT_TARGET env var
This is true, the compiler does set this as the docs say so.
You don't need to use the 10.3.9 SDK to support 10.3.9, the SDK only describes the highest version of Mac OS X you support. You determine the lowest version of Mac OS X you support by setting the "Mac OS X Deployment Target" in the target's build options.
Any function that is supported on your Deployment target or earlier are hard linked (and your software won't load on earlier versions of the OS). Any functions that were introduced after your deployment
target are weak linked.
AvailabilityMacros.h says that by setting MAC_OS_X_VERSION_MAX_ALLOWED you can cause certain things to be unavailable.
I guess I'll be reporting a bug.
Regards, David Alger Any functions introduced after your SDK version are unavailable.
Then any APIs that you use that were defined after your deployment target, but before your SDK version must be tested for availability before you call them, which is typically done by checking against NULL. If they are not available, you can't call them. ----
Hope that helps,
-- ____________________________________________________________ Rogue Research www.rogue-research.com Mac Software Developer Montréal, Québec, Canada
-- David Alger, Software Engineer Family Friendly Software, LLC
Looking for a reliable, affordable, and customer oriented web host? With BlueHost you get a FREE domain name and FREE setup plus a first-class hosting package for ONLY $6.95 a month!
|