Re: Error when compiling blocks code in Snow Leopard
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com % 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' -- Greg Parker gparker@apple.com Runtime Wrangler _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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: <rdar://problem/6499343> 10A241: Impossible to have Block local vars in C++ within a method declaration This email sent to site_archiver@lists.apple.com
participants (1)
-
Greg Parker