On Oct 12, 2012, at 12:46 AM, Dave Keck wrote: >> 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.
It is legal. C99 requires initializers of objects of static storage duration (e.g. globals) to be constant-expressions, but that's defined fairly broadly as essentially anything that doesn't involve a load, a store, or a call. There's nothing about the expression involving the variable's own address that's problematic. John. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com