Re: Unavailable Function Errors and Backwards Compatability
Re: Unavailable Function Errors and Backwards Compatability
- Subject: Re: Unavailable Function Errors and Backwards Compatability
- From: "Sean McBride" <email@hidden>
- Date: Thu, 15 Mar 2007 10:10:00 -0400
- Organization: Rogue Research
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? 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.
>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*. 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
http://lists.apple.com/archives/xcode-users/2005/Aug/msg00399.html
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. 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,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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