Possible Duplicate:
How do I fix “for loop initial declaration used outside C99 mode” GCC error?
Why must I declare a loop variable outside of the for loop statement? I am getting a gcc (MacOSX) error which reads:
error: ‘for’ loop initial declaration used outside C99 mode
If I define my loop variable outside of the loop statement then gcc stops complaining.
As the error suggests, this is because declaring a variable inside the condition of a for-loop wasn't allowed until C99, and you are using an older language standard. If you're compiling directly, use the -std=c99
flag. In Xcode, go to the "Compiler - Language" options for your target and set the Language Standard to either C99 or GNU99.
You need to compile with the option -std=c99
.
For example:
$ gcc -std=c99 code.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With