The compiler reports the line where it noticed the problem, which is often one line after the mistake. Look at the line above the one it names.
What the message means
A missing semicolon or brace is only noticed when the next token appears. So “expected ‘;’ before X” points at X, but the missing mark is just before it.
Fix it in this order
- Open the line named in the message, then read the line above it for a missing semicolon.
- Count braces. Every opening brace needs a closing one. The IDE highlights the partner when you click next to a brace.
- Use Tools > Auto Format. Odd indentation shows where a brace is missing.
- Check that every statement inside a function ends in a semicolon and that a class or struct ends with }; .
- Look for a stray character pasted from a web page, such as a curly quote.
- Comment out code in halves until the error disappears, to find the block that causes it.
If you see this, do this
| You see | Do this |
|---|---|
| Error at the last line | A closing brace is missing somewhere above. |
| Error after a #define | Do not end a #define with a semicolon unless you need one. |
| Error after pasting code | Replace curly quotes with straight quotes. |
Related
was not declared in this scope, Arduino IDE setup.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.