Why does a case
statement allow declarations within braces but not without them?
For example, the following is not OK
switch (op->name) {
case 0:
int a = 2;
case 1:
int b = 3;
}
But the following is OK:
switch (op->name) {
case 0:
{int a = 2;}
case 1:
{int b = 3;}
}
What does the braces resolve that, without them, a declaration would be ambiguous to the compiler? To me (a beginner in C) it seems like each case statement should have an implied braces until the next case/default/end-of-switch, but that is obviously wrong!