Xcode GCC-4.0 vs 4.2

I just changed the compiler option from 4.0 to 4.2.

Now I get the error message:

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

It works great in 4.0

Any ideas?

+5
source share
2 answers

Just guess - you are declaring a variable (possibly const char*) inside 1 of your case-switch statement - you must wrap this case in {} to fix this.

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

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

You probably declare a variable inside the case without wrapping it all in parenthesis:

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

Must be:

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

All Articles