Possible Duplicate:
Why can't variables be declared in a switch statement?
I saw somethere that in C the initialization of a variable can be skipped by a jump statement, as in the following example:
/* valid in C but not C++ */
int main()
{
switch (1)
{
case 0:
int foo = 0;
break;
case 1:
++foo;
}
return 0;
}
But when i try to compile it with Comeau compiler there are errors:
"ComeauTest.c", line 8: error: a declaration cannot have a label int foo = 0; ^
"ComeauTest.c", line 5: warning: transfer of control bypasses initialization of: variable "foo" (declared at line 8) switch (1) ^