The default C dialect for GCC and ICC is GNU89. GNU89 allows mixed declarations like
int i; i = 0; int j;
I assumed (incorrectly) from a number of other posts in SO, like C: for the initial declaration of an int loop , which meant that 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 initial cycle declarations are not the same thing (i.e., do not mean the other).
If I had only one, I would prefer to have initial loop declarations. Of course, I could use GNU99, but that is not the point. GNU89 is used by default, and it already violates some C89 rules (it also allows the use of BCPL / C ++ style comments). Is there any fundamental reason why mixed declarations are allowed, but are not initial cycle declarations?
c gcc c99 c89
Z boson Apr 22 '14 at 20:47 2014-04-22 20:47
source share