Re: Building for earlier OS X versions : Check for NULL *address* of constants
Re: Building for earlier OS X versions : Check for NULL *address* of constants
- Subject: Re: Building for earlier OS X versions : Check for NULL *address* of constants
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 29 Apr 2013 09:15:12 +0200
Le 29 avr. 2013 à 03:59, Jerry Krinock <email@hidden> a écrit :
> In Apple's SDK Compatibility Guide > Using SDK-Based Development, it says…
>
> "Check the availability of an external (extern) constant or a notification name by explicitly comparing its address — and not the symbol’s bare name — to NULL or nil."
>
> It also says, regarding C *functions* that "the linker sets the address of unavailable functions to NULL". Do they mean during the linking phase of building, or when the program loads (runtime)?
They mean the dynamic linker. It happens at load time, not at compile time.
> More importantly, is the following code correct? It looks weird.
While it may look weird, this is the way to do it.
>
> NSString* identifier ;
> if (&NSWorkspaceApplicationKey != NULL) {
> // We are running in Mac OS X 10.6 or later
> identifier = <expression using the bare name: NSWorkspaceApplicationKey> ;
> }
> else {
> // We are running in Mac OS X 10.5
> identifier = <some other expression> ;
> }
-- Jean-Daniel
_______________________________________________
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