Re: Multiple variable rules in for() statement

2009-11-14 Thread Clark Cox
On Thu, Nov 12, 2009 at 11:50 AM, David Ross dbr...@nushield.com wrote: Jonathon, GCC does not like declaring variables in a for statement. It likes it just fine. You just need to build as C99 (or GNU99). -- Clark S. Cox III clarkc...@gmail.com ___

Re: Multiple variable rules in for() statement

2009-11-13 Thread David Ross
Jonathon, GCC does not like declaring variables in a for statement. If you want to make the variable m have the scope for only the for loop, you would need: foo() { ... { int i, m; for (i=0, m=0; i5; i++){...} printf(Final value of

Re: Multiple variable rules in for() statement

2009-11-13 Thread Andrew Farmer
On 12 Nov 2009, at 11:50, David Ross wrote: GCC does not like declaring variables in a for statement. Adding -std=c99 or -std=gnu99 to the compiler flags will fix that. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin

Multiple variable rules in for() statement

2009-11-12 Thread Jonathon Kuo
I can't chance upon the right incantation for using both an existing variable and an inline new one in a for loop. I've boiled this down to a trivial show case, same results for both gcc 4.0.1 and 4.2.1: int i; . . . for (i=0, int m=0; i5; i++) { . . . }; printf(Final value of i:

Re: Multiple variable rules in for() statement

2009-11-12 Thread BJ Homer
I believe this is actually independent of being in a for loop. Your first line corresponds to code like this: int i; i=0, int m=0; Which is syntactically incorrect. Your second example corresponds to this: int i; int m=0, i; Which is an attempt to re-declare i. So you're correct; you can't

Re: Multiple variable rules in for() statement

2009-11-12 Thread Greg Parker
On Nov 12, 2009, at 11:29 AM, Jonathon Kuo wrote: I can't chance upon the right incantation for using both an existing variable and an inline new one in a for loop. I've boiled this down to a trivial show case, same results for both gcc 4.0.1 and 4.2.1: int i; . . . for (i=0, int

Re: Multiple variable rules in for() statement

2009-11-12 Thread Jonathon Kuo
On Nov 12, 2009, at 12:14 PM, Greg Parker wrote: On Nov 12, 2009, at 11:29 AM, Jonathon Kuo wrote: I can't chance upon the right incantation for using both an existing variable and an inline new one in a for loop. I've boiled this down to a trivial show case, same results for both gcc 4.0.1