Re: Determining OS at Runtime
Re: Determining OS at Runtime
- Subject: Re: Determining OS at Runtime
- From: Jim Correia <email@hidden>
- Date: Fri, 3 Jul 2009 13:31:54 -0400
On Jul 3, 2009, at 1:06 PM, Steve Christensen wrote:
For the case of a function, if you're deploying on 10.4 but using a
10.5 function, that function will be weak-linked so doing a runtime
check is both faster and more accurate in determining whether a
function exists or not.
Beware that there have been edge cases in the past where a non-NULL
function test will give you a false positive with disastrous results.
It goes like this:
if (FunctionName != NULL) {
FunctionName(x, y, z);
}
FunctionName was SPI on 10.x but (inadvertently) exported, but API on
10.y.
When running on 10.x, your NULL function pointer test will pass, but
this is SPI and isn't supported for use. The signature may have
changed, or the range of valid input values may be a subset of the
supported ones on 10.y.
This is not a theoretical problem, but one which has happened in the
past.
What is the take home lesson here? Test all branches of the code you
write.
Jim
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden