Andrey Tarasevich <an**************@hotmail.com> writes:
Keith Thompson wrote: > Thanks - I just found it strange because this has been allowed
> before c99 - mabee not in the ansi c standard but all the
> compilers i have worked with has compiled code like this without
> complainning - it seams that it first officialy became a part of
> the legal syntax in ansi C with c99.
> ....
It is highly unlikely that you could compile this code with any pre-C99
C compiler. Most likely you were using C++ compilers. There's nothing
strange in the fact that C++ allows this and C89/C90 doesn't.
I think pre-C99 versions of gcc provide this as a language extension.
Other compilers may provide similar extensions.
...
Yes, but if I'm not mistaken, these extensions needed to be explicitly
enabled before they could be used, which normally makes the user to
understand that he is using an extension, not a standard feature.
It depends on the compiler. gcc, by default, enables a number of
language extensions; you have to give it extra command-line options to
disable the extensions and turn it into a (more or less) conforming
ISO C compiler. I've seen similar command-line options in other
compilers.
In this particular case, though, you appear to be correct; gcc rejects
"for (int i = 0; i < 10; i ++)" unless you specify C99 mode.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)