Re: C arrays as __block variables
Re: C arrays as __block variables
- Subject: Re: C arrays as __block variables
- From: Tony Romano <email@hidden>
- Date: Sat, 26 Jun 2010 23:13:17 -0700
The reason for the __block specifier is to allow the variable to be written to. If the variable remains a const, then the complier can optimize how the block is stored. If the data is changed, much of the optimization is lost.
-Tony
On Jun 26, 2010, at 8:56 PM, Kyle Sluder wrote:
> On Sat, Jun 26, 2010 at 8:51 PM, Tony Romano <email@hidden> wrote:
>> OP posted: "This would seem to imply that a __block variable *can* be a *fixed* length
>> array. But when I try to write into such an array inside a block, I get a
>> compile error, "cannot access __block variable of array type inside block."
>>
>> 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]);
>
> Putting __block variables inside of blocks is completely pointless.
> The purpose of the __block qualifier is to mark variables in the
> enclosing scope to be copied into the block.
>
> --Kyle Sluder
>
-Tony
_______________________________________________
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