Jump to case label

Hi I have a video game shield that keep giving me a jump to case error in a switch case loop. How do I fix this?

Also my code is to long to post in the code brackets so ill attach it.

Selector.ino (15.3 KB)

A line # and dump of the errors would be good, we don't all have the same environment in place.


Rob

hadjisra:
Hi I have a video game shield that keep giving me a jump to case error in a switch case loop. How do I fix this?

I can't guess what the error is, but that's a pretty big nested switch statement in loop(). Consider pulling the logic for each game into a separate function? Depending what's causing the problem it might fix it by accident, but mainly it'll simplify the code structure.

I was about to say what PeterH did. Your nested switch is confusing to say the least. And post the actual errors and indicate which line number it is referring to.

ok the actual error is as follows:

jump to case label
Selector.cpp: In function 'void loop()':
Selector:712: error: jump to case label
Selector:662: error: crosses initialization of 'int throttle'
Selector:660: error: crosses initialization of 'char* speed_options [6]'
Selector:656: error: crosses initialization of 'char* options [3]'
Selector:763: error: 'determine_victory' was not declared in this scope

hadjisra:
Selector:662: error: crosses initialization of 'int throttle'
Selector:660: error: crosses initialization of 'char* speed_options [6]'
Selector:656: error: crosses initialization of 'char* options [3]'

So it's saying that you jump across the initialization of several variables. That means that they are still in scope, but they haven't been initialized. So you can either put a pair of braces around the cases that initialize variables (thereby creating a new scope) or initialize the variables before the switch statement.

Many years later, the solution provided by WizenedEE worked a treat.
Transferred some code that did work in the loop into a switch case "case" and it came up with a load of errors like the OP's which meant nothing to me.
Curly braces around the transferred code and all was well. Shame the OP didn't report back
Thank you