The default C dialect for GCC and ICC is GNU89. GNU89 allows mixed declarations e.g.
int i;
i = 0;
int j;
I inferred (incorrectly) from a number of other posts on SO e.g C: for loop int initial declaration, that this meant I could do
for(int i=0; i<n; i++)
with GNU89 but when I do this I get
error: 'for' loop initial declarations are only allowed in C99 mode
Apparently, mixed declarations and loop initial declarations are not the same thing (i.e. one does not imply the other).
If I could only have one I would rather have loop initial declarations. Of course, I could just use GNU99 but that's not the point. The default is GNU89 and it already breaks some C89 rules (it also allows BCPL/C++ style comments). Is there some fundamental reason why mixed declarations are allowed but not loop initial declarations?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…