views:

137

answers:

2

I have just changed a compiler option from 4.0 to 4.2.

Now I get an error:

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

It works fine in 4.0

Any ideas?

+1  A: 

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.

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

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

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;
}
Mike Weller