4
I made the following command:
for(int i = 1 ; i <= 3 ; i++) {etc
}
Then it made the following mistake when I went to compile:
game.c:11:2: error: "for" loop initial declarations are only allowed in C99 mode
for(int i = 1 ; i <= 3 ; i++) {
/\ //essa seta apontando pro "f"
game.c:11:2: note: use option -std=c99 or -std=gnu99 to compile your code
What to do?
As the error message itself said, use the option
-std=c99
or-std=gnu99
when calling the compiler (or moving theint i
out of the loop). Apparently you cannot declare a variable inside afor
in the version of C you are using (this can from C99).– mgibsonbr
For reference, the difference between using
c99
andgnu99
is that this second allows GNU extensions (i.e. gcc-specific), while the first follows more strictly the specification. So if you want code portable (which can be compiled by other types of C compiler), use the first, if you want/need some specific extension, use the second.– mgibsonbr