On 2 February 2014 18:27, Xin Tong <trent.t...@gmail.com> wrote: > On Sun, Feb 2, 2014 at 10:19 AM, Peter Maydell <peter.mayd...@linaro.org> > wrote: >> Statement expressions are supported by both gcc and clang, >> which is the set of compilers we care about. > > Ok got it. would moving vtlb_idx inside the macro break the C89 rule > of "No Variable declaration in middle of block"
No, because the macro has a block inside it. "block" means "a chunk of code inside {}", not "an entire function". You can declare variables at the start of functions, or at the start of the block in a while loop, or at the start of the blocks in an if () {...} else {...}, or (as in this case) at the start of the block inside a C statement expr. If you want to restrict the scope of a variable and you don't have a block conveniently to hand, it's always valid just to create one: C syntax allows a bare "{ /* code here */ }" anywhere a statement is valid. It's almost always the case that there's some handy control-flow-mandated block to use, though. thanks -- PMM