Arduino build error

error: expected ';' before '}' token

The compiler reached the end of a statement and found no semicolon, so it stops at the next token.

  • Build error
  • 3 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:4:25: error: expected ';' before '}' token
    4 |   Serial.println(count)
      |                        ^
exit status 1

The reported line is where the compiler noticed. The missing semicolon is almost always at the end of the line above it.

Mokxi's compiler, clang, words it as expected ';' after expression, and points just after the last character of the line that needs the semicolon.

Causes

The 3 usual causes with the fix

1A statement has no semicolon at its end

Every statement ends with a semicolon: a call, an assignment, a variable. Look at the end of the line before the one in the message.

Broken
void setup() {
  Serial.begin(9600);
  int count = 3;
  Serial.println(count)
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int count = 3;
  Serial.println(count);
}

void loop() {
}

Mokxi’s build tab says: A semicolon (;) is missing.

Try this fix in Mokxi

2A struct or class definition needs one after its closing brace

A struct ends with }; and the semicolon is part of the definition. Without it the compiler reads the next line as part of the struct.

Broken
struct Point {
  int x;
  int y;
}

Point spot = {3, 4};

void setup() {
  Serial.begin(9600);
  Serial.println(spot.y);
}

void loop() {
}
Fixed
struct Point {
  int x;
  int y;
};

Point spot = {3, 4};

void setup() {
  Serial.begin(9600);
  Serial.println(spot.y);
}

void loop() {
}

Mokxi’s build tab says: A semicolon (;) is missing.

Try this fix in Mokxi

3A variable at the top of the file has no semicolon

Global variables end with a semicolon too. The error then shows up on the line below, where the next function starts.

Broken
int count = 3

void setup() {
  Serial.begin(9600);
  Serial.println(count);
}

void loop() {
}
Fixed
int count = 3;

void setup() {
  Serial.begin(9600);
  Serial.println(count);
}

void loop() {
}

Try this fix in Mokxi

FAQ

Questions and answers

What does "expected ';' before" mean in Arduino?

A statement is missing the semicolon that ends it. The compiler only notices when it reaches the next token, so the line in the message is the line after the mistake.

Why does the error point at a line with a semicolon?

The line in the message is where the compiler gave up. Check the end of the line above it first.

Does a #define or #include need a semicolon?

No. Lines that start with # are instructions to the preprocessor and never end with a semicolon.