Fix “expected ; before” in an Arduino sketch
Reproduce a missing semicolon in AVR-GCC and find the unfinished statement immediately before the highlighted token.
Start with the first compiler diagnostic
The highlighted token is often the first token the parser could not fit into a statement. If it points at delay(), check the complete statement above it before changing delay(). Missing right parentheses or braces can also shift the reported location. Fix the first real diagnostic and rebuild before addressing a cascade.
Make the controlled change
Open the corrected Uno example and compile it. Delete only the semicolon after digitalWrite and compile again. Read the diagnostic in Output, restore the semicolon, then verify again. An if condition uses a closing parenthesis. Placing a semicolon after the condition can change the program even when the compiler accepts it.
Open the exact Uno example
The corrected source compiles. Removing the semicolon above delay reproduces the parser diagnostic.
void setup() { pinMode(LED_BUILTIN, OUTPUT); }
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
}Verified with [email protected] on Uno R3 (2026-12-05 UTC). The intentionally broken variant reproduced the named diagnostic. This check did not use physical hardware.