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: Nico Schmidt <email@hidden>
- Date: Fri, 4 Sep 2009 00:45:27 +0200
On 03.09.2009, at 23:42, Terry Lambert wrote:
On Sep 3, 2009, at 1:48 PM, Greg Parker wrote:
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:
Then perhaps my observation about the compiler option that causes
this to happen in C code as well will be helpful in identifying a
root cause in the C++ compiler?
-- Terry
Actually the following code fails to compile with the same message:
typedef void (^dispatch_block_t)();
class Foo {
void Bar()
{
dispatch_block_t b =
^{
int i = 1;
};
}
};
block.cpp: In function ‘void __Bar_block_invoke_1(void*)’:
block.cpp:7: error: ‘int Foo::i’ is not a static member of ‘class
Foo’
while the following with an explicit scope for i works:
typedef void (^dispatch_block_t)();
class Foo {
void Bar()
{
dispatch_block_t b =
^{
int ::i = 1;
};
}
};
Any thoughts?
Nico _______________________________________________
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