Re: Error when compiling blocks code in Snow Leopard
Re: Error when compiling blocks code in Snow Leopard
- Subject: Re: Error when compiling blocks code in Snow Leopard
- From: Greg Parker <email@hidden>
- Date: Thu, 3 Sep 2009 13:48:41 -0700
On Sep 3, 2009, at 1:40 PM, Terry Lambert wrote:
The C++ standard limits the scope of variables declared like you are
declaring 'i' (as a for-init-statement, technically) to the for
itself, rather than extending to the end of the enclosing scope.
This is a standards related change in behaviour from traditional C++/
g++, which, while not permitted by the standard, is how old
compilers tended to be implemented, not having an explicit indicator
for interior scope ends in their parse tree representation.
There's nothing wrong with his `for` scope here; he didn't use `i` at
all, much less use it out of scope. A block-local variable in a C++
method fails the same way with no loop at all:
% cat test.cc
class Foo {
void Bar() {
^{ int i; };
}
};
% c++ test.cc
test.cc: In function 'void __Bar_block_invoke_1(void*)':
test.cc:3: error: 'int Foo::i' is not a static member of 'class Foo'
<rdar://problem/6499343> 10A241: Impossible to have Block local vars
in C++ within a method declaration
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden