On Tue, 2003-04-15 at 15:04, Jerry Feldman wrote:
On 15 Apr 2003 06:25:32 +0200 Anders Johansson <andjoh@rydsbo.net> wrote:
That is what I was thinking of, yes, but it's not just in c++. In K&R C it was allowed to have things like
for (int i = 0; i < 5; i++){ fprintf(stderr, "foo\n"); int a = 3; } I don't think this was every legal in K&R and I know it is not in C89. For one, K&R never allowed the initialization of automatic variables,
I'm sure you don't actually mean that K&R actually banned giving values to automatic variables, but if you mean "initialization at time of declaration", I can't really argue the subject with any authority since the only book still in my bookshelf is the second edition, so I can't give any quotes about K&R C. All I can say is that I've seen it in compilable code (a long time ago).
but as I mentioned, some compilers did. As you mention, the above code is legal in C++. I'm not sure about C99.
Neither am I, I haven't actually seen the C99 standard, but gcc complains if set to -std=c89 but not if set to -std=c99. Hence "apparently" in my previous mail.