I was playing with some syntax and found some strange compiler rules, was wondering what the reasoning is for this
C will not compile this but C++ will:
switch (argc) {
case 0:
int foo;
break;
default:
break;
}
Both C and C++ will compile this:
switch (argc) {
case 0:
; int foo;
break;
default:
break;
}
C will compile this but not C++:
switch (argc) {
case 0:
; int foo = 0;
break;
default:
break;
}
gcc -v
is gcc version 4.9.3 (MacPorts gcc49 4.9.3_0)
if it matters. I realize the solution is to wrap the contents of case 0:
with curly brackets, but I am more interested in the reasoning for compilation errors