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: Dave Keck <email@hidden>
- Date: Thu, 11 Oct 2012 21:46:11 -1000
> staticvoid *AVSPPlayerItemStatusContext = &AVSPPlayerItemStatusContext;
This declares a unique pointer, whose value is defined as the address in memory where the pointer lives.
This technique can be useful when you need a value that's reasonably assured to be unique -- i.e., this technique guarantees that the value is unique with respect to all other statically- or dynamically- allocated memory in the process. (The pedantic caveat being that if some other piece of code chooses to use a context pointer that's just a randomly-generated number, there's of course a chance of collision.)
I'm unsure whether this is compliant C99, but it's common enough that I would expect Clang/LLVM to continue compiling it in the future.
_______________________________________________
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