简体   繁体   English

XCode GCC-4.0与4.2

[英]XCode GCC-4.0 vs 4.2

I have just changed a compiler option from 4.0 to 4.2. 我刚刚将编译器选项从4.0更改为4.2。

Now I get an error: 现在我得到一个错误:

jump to case label crosses initialization of 'const char* selectorName'

It works fine in 4.0 在4.0中工作正常

Any ideas? 有任何想法吗?

Just a guess - you declare variable (probably const char* ) inside 1 of your switch-case statements - you should wrap that case in {} to fix that. 只是一个猜测 -您在switch-case语句的1个内部声明了变量(可能是const char* )-您应该将这种情况包装在{}中以解决该问题。

// error
case 1:
   const char* a = ... 
   break; 

// OK
case 1:{
   const char* a = ... 
}
   break; 

You probably declare a variable inside a case without wrapping it all in a brace: 您可能在案例中声明了一个变量,而没有将其全部括在大括号中:

case foo:
    const char* selectorName;
    // ...
    break;

Should be: 应该:

case foo: {
    const char* selectorName;
    // ...
    break;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM