Re: static void declaration in apple example code
Re: static void declaration in apple example code
- Subject: Re: static void declaration in apple example code
- From: Greg Parker <email@hidden>
- Date: Fri, 12 Oct 2012 00:39:41 -0700
On Sep 22, 2012, at 4:46 PM, Boris Dobroslav <email@hidden> wrote:
> I'm perplexed by one line that appears in the file AVSPDocument.h from the apple example code project AVSimplePlayer:
>
> staticvoid *AVSPPlayerItemStatusContext = &AVSPPlayerItemStatusContext;
>
> This definition appears outside of Objective-C @interface or @implementation, so it must be pure C. But isn't it self-referential? Is it a C idiom? Any pointers would be appreciated.
The intent is to get a unique pointer that differs from every other pointer value. The code can then use that address as a unique key or sentinel.
The fact that this line takes the address of a global variable and stores that address in the same global variable is just a clever trick that is legal in C.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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