• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: static void declaration in apple example code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >static void declaration in apple example code (From: Boris Dobroslav <email@hidden>)

  • Prev by Date: Self contained command line tool
  • Next by Date: Re: static void declaration in apple example code
  • Previous by thread: static void declaration in apple example code
  • Next by thread: Re: static void declaration in apple example code
  • Index(es):
    • Date
    • Thread