• 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: C arrays as __block variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C arrays as __block variables


  • Subject: Re: C arrays as __block variables
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 27 Jun 2010 08:43:33 -0700
  • Thread-topic: C arrays as __block variables

>>> In the example I listed below, I have a __block variable inside a block that
>>> is fixed length array and I can access it via  NSLog(@"char %c", array1[0]);

Sure, but I'm talking about a __block variable declared outside the block:

    int arr[1];
    ^(){ arr[0];}; // compile error


    __block int arr[1];
    ^(){ arr[0]; }; // compile error!

I think b.bum has explained this thoroughly; the workaround is:

    struct {int arr[1];} str;
    ^(){ str.arr[0];};

And now it can be made writable with __block as expected:

    __block struct {int arr[1];} str;
    ^(){ str.arr[0]=1;};

I would suggest the docs be a bit more forthcoming about this, unless it's
documented and I just didn't spot it. Thx all - m.

--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



_______________________________________________

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: 
 >Re: C arrays as __block variables (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: C arrays as __block variables
  • Next by Date: [Possible Bug] Keyboard causes popover content view to scroll out of bounds
  • Previous by thread: Re: C arrays as __block variables
  • Next by thread: Re: C arrays as __block variables
  • Index(es):
    • Date
    • Thread