On several compilers I have used (all gcc but various versions) I get a C99 mode error for things like declaring int i inside the for loop expression instead of before it (if I do not use the std=c99 option). After reading here I understand that the gcc options -ansi, -std=c89, and -std=iso9899:1990 all evaluate to the ANSI C standard, but I don't understand why/if I should pick the c89 standard versus a newer standard like c99 (which is the newest I assume).
Also, I see multiple versions of the iso type standards for the C language, the first of which (from my understanding) is a direct port of the ANSI standard. Is is safe to say that iso will update their standard for C but the original ANSI standard for C will always be the same?
Bonus question:
I can actually figure this one out myself, I just haven't taken the time to do it yet, so if someone knows off the top of their head then that is great, otherwise no biggie, I'll figure it out later :)
I have a fairly new print of the book The C Programming Language (ANSI). My book always shows for loops like this:
int i;
for(i = 0; i < foo; i++)
but many people (most of who have more programming talent in their little finger) write their for loops like this:
(int i = 0; i < foo; i++)
Is it correct to say if I write the loop the first way then i should be accessible to the entire function, but if I write it the second way then i is only accessible to the for loop REGARDLESS of what standard I compile with? Another way of asking this same question, if I compile with the c89 standard will the i of both for loops be accessible to the entire function and if I compile with the c99 standard will the i of the first for loop be accessible to the entire function while the i of the second for loop will be accessible by only the for loop?