lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 8/30/05, Rici Lake <> wrote:
> That fails to declare i. Actually, I should have written the C line
> as follows:
> { int i; for (i = 1; i <= 10; ++i) { ... } }
> You could actually write that as a macro in C9x, taking advantage
> of the bizarre syntax for declaring control variables inside for
> expressions. But afaik there is no way of doing that in C90.

I think this abides by C90:

#define DO(var,from,to,body) {int var; for (var=from; var<=to; ++var) {body}}

I ran it with  DO(i,0,9, printf("i = "); printf("%d\n",i););

through gcc and it worked as needed.