K
Keith Thompson
pemo said:Flash Gordon said:pemo wrote:
I'm still a bit 'old school' I'm afraid, and typically declare my
variables at the top of a function - no matter where they're used in that
function.
Many years ago, I would have loved having some mechanism that allowed me
to declare them 'nearer' to where they were used - but, then, C wouldn't
allow that. Nowadays, [being an 'old dog' that can't learn 'new tricks']
I stick
Must be very old school, since it is allowed by C89.
Um, let's see - can't remember exactly when I started, but it was around
1980 [and I used to be quite good at it then I believe]
Ok, that's pre-ANSI, but I think it's post-K&R1.
As far as I know, the following was legal even back then:
main()
{
int function_scope_var;
{
int block_scope_var;
}
{
int another_block_scope_var;
}
}
Were you using a compiler that didn't allow it?
(Of course mixing declarations and statements wasn't allowed until C99.)