Arduino build error

error: jump to case label [-fpermissive]

All cases of a switch share one block. A variable made inside one case would exist, unset, when another case runs. C++ refuses that.

  • Build error
  • 2 common causes
  • Seen 2,761 times in failed builds on Mokxi in the 30 days to November 16, 2026.
The message

What the Arduino IDE prints

Output window
sketch.ino: In function 'void setup()':
sketch.ino:9:5: error: jump to case label [-fpermissive]
sketch.ino:7:9: note:   crosses initialization of 'int level'
exit status 1

Put the case in its own curly brackets, or make the variable before the switch.

Mokxi's compiler, clang, words it as cannot jump from switch statement to this case label, with a note about the variable.

Causes

The 2 usual causes with the fix

1A variable is declared inside a case

Wrap the case body in curly brackets so the variable lives only there.

Broken
void setup() {
  Serial.begin(9600);
  int mode = 2;
  switch (mode) {
    case 1:
      int level = 5;
      Serial.println(level);
      break;
    case 2:
      Serial.println("two");
      break;
  }
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int mode = 2;
  switch (mode) {
    case 1: {
      int level = 5;
      Serial.println(level);
      break;
    }
    case 2:
      Serial.println("two");
      break;
  }
}

void loop() {
}

Mokxi’s build tab says: A case above declares a variable, and the switch would jump past it

Try this fix in Mokxi

2The variable is only needed by one case but made first

Make the variable before the switch when several cases use it.

Broken
void setup() {
  Serial.begin(9600);
  int mode = 2;
  switch (mode) {
    case 1:
      int total = 1;
      Serial.println(total);
      break;
    default:
      Serial.println("other");
      break;
  }
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int mode = 2;
  int total = 1;
  switch (mode) {
    case 1:
      Serial.println(total);
      break;
    default:
      Serial.println("other");
      break;
  }
}

void loop() {
}

Mokxi’s build tab says: A case above declares a variable, and the switch would jump past it

Try this fix in Mokxi

FAQ

Questions and answers

Why can I declare a variable in an if but not in a case?

An if body is its own block. The cases of a switch are labels inside one block, so a jump can skip a declaration.

Is a variable without a value also an error?

No. Only a variable that is set up with a value or an object trips this. int level; alone compiles.

Should I wrap every case in brackets?

Only the ones that declare variables. Brackets on all of them are harmless and make the code uniform.