Blocks in C++ class vs. Obj-C class
Blocks in C++ class vs. Obj-C class
- Subject: Blocks in C++ class vs. Obj-C class
- From: Rick Mann <email@hidden>
- Date: Sat, 12 Mar 2011 18:45:59 -0800
I've noticed a difference in the way local variables in blocks are handled in C++ classes vs. Objective-C classes. Take the following example, where all of this is compiled in a .mm file:
class Foo
{
void foo();
};
void
Foo::foo()
{
^{
int a = 1; // Error: 'int Foo::a' is not a static member of 'class Foo'
};
}
@interface Bar
- (void) bar;
@end
@implementation Bar
- (void)
bar
{
^{
int a = 1; // no error
};
}
@end
Why can I not assign to a locally-declared variable in a block that exists within a C++ method, but I can in an Objective-C method?
This is Xcode 3.2.5, gcc-4.2
Thanks,
Rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden