Block Structure Declarations
jim at kovacs.UUCP
jim at kovacs.UUCP
Fri May 25 01:59:31 AEST 1984
>
According to K&R in "The C Programming Language" Sect 4.8, page 81:
"Declarations of variables (including initializations)
may follow the left brace that introduces *ANY* compound
statement, not just the one that begins a function.
Variables declared in this way supersede any identically
named variables in outer blocks..."
Three examples are given. One example not given is:
f(x)
double x;
{
short x;
...
}
Within function "f", occurences of "x" refer to the internal "short"
variable. The compiler will not say a word about this. Lint says
"argument x unused in function f". Since I cannot think of a single
case where one would intentionally do this, I think the compiler
should warn that argument x is being redeclared.
-Jim Keating-
R. Abel & Assoc.
Hollywood, CA 90038
(213) 462 8100
More information about the Comp.lang.c
mailing list