我刚刚将编译器选项从 4.0 更改为 4.2。
现在我得到一个错误:
jump to case label crosses initialization of 'const char* selectorName'
它在 4.0 中运行良好
有任何想法吗?
我刚刚将编译器选项从 4.0 更改为 4.2。
现在我得到一个错误:
jump to case label crosses initialization of 'const char* selectorName'
它在 4.0 中运行良好
有任何想法吗?
只是一个猜测-您在 switch-case 语句的 1 中声明变量(可能const char*
)-您应该将该案例包装在 {} 中以解决该问题。
// error
case 1:
const char* a = ...
break;
// OK
case 1:{
const char* a = ...
}
break;
您可能会在 case 中声明一个变量,而无需将其全部包装在大括号中:
case foo:
const char* selectorName;
// ...
break;
应该:
case foo: {
const char* selectorName;
// ...
break;
}