Pelle,
The compiler doesn't catch redeclaration of global vars.
e.g.
int a, a;
int main(void) {...}
It catches redeclaration of auto vars, though.
ds
Just a quick test: one Microsoft, and one GNU, compiler seems perfectly happy with this - not even a warning. I will see if the C standard says anything about it... (not sure it does).
Pelle
I think it could be consistent with the sharing of global variables.
If I well remember M$ C compiler (the old DOS version at least) automatically allocate a global variable if are present one or more external declarations of the same variable (i.e. "#external int a"), also if there is no allocation (i.e. "int a") in any module.
Of course defining the same variable on the same line and in the same module seems odd, but sintactically correct for the language grammar.
My old DOS Borland C v3.1 complains about it. Well anyways. I see no reason why there should not be at least a warning. It took me a long time to debug till I finally realized I had accidently declared 2 variables with the same name. Are there any reasons ?
Seems to be OK with the C standard. No bug, no warning.
(If you really need to catch this - why not intialize the variables? "int a = 0, a = 0;" is a different matter, and will cause an error...)
Pelle
I don't see practical problems if the variable is the same, if you mean that the compiler accept the redeclaration and create different variables then we have a big problem.
It's the same...