[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntax and redundancy
- From: Boyko Bantchev <boykobb@...>
- Date: Tue, 30 Aug 2005 19:23:53 +0300
On 8/30/05, Rici Lake <lua@ricilake.net> 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.
- References:
- Syntax and redundancy, Gavin Wraith
- Re: Syntax and redundancy, Philippe Lhoste
- Re: Syntax and redundancy, Rob Kendrick
- Re: Syntax and redundancy, David Olofson
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Aaron Brown
- Re: Syntax and redundancy, Adrian Perez
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Boyko Bantchev
- Re: Syntax and redundancy, Rici Lake