Odd behaviour of the compiler when using loops
Posted: Tue Nov 13, 2012 7:44 pm
I was wondering whether to put this in the libnds section or here, but figured that compilation rules fall under devkitARM.
Here's the issue - the standard syntax in a for loop in C is
for(StartingExpression; TestingExpression;Count){...}
...so for example
for(i=0;i<5;i++){...}
and this of course works. However, when I use
for(i=0;i<6;i+2){...}
compilation fails. Instead, I have to use a whole assignment to create a full statement for Count, such as
for(i=0;i<6;i=i+2){...}
or
for(i=0;i<6;i+=2){...}
I've read examples and texts on the subject listing the second statement as entirely valid - why the error? Has the standard changed?
I'm working on Windows 7 x64 with an unaltered, latest version of the kit and I'm using the make command to compile, thanks in advance for any replies and insight on the cause of this behaviour. Does the last argument have to be a whole expression?
Here's the issue - the standard syntax in a for loop in C is
for(StartingExpression; TestingExpression;Count){...}
...so for example
for(i=0;i<5;i++){...}
and this of course works. However, when I use
for(i=0;i<6;i+2){...}
compilation fails. Instead, I have to use a whole assignment to create a full statement for Count, such as
for(i=0;i<6;i=i+2){...}
or
for(i=0;i<6;i+=2){...}
I've read examples and texts on the subject listing the second statement as entirely valid - why the error? Has the standard changed?
I'm working on Windows 7 x64 with an unaltered, latest version of the kit and I'm using the make command to compile, thanks in advance for any replies and insight on the cause of this behaviour. Does the last argument have to be a whole expression?