gcc/clang "error: expected ';' before" in CI
The parser expected a semicolon and found something else. The reported line is usually correct but the missing semicolon is often on the line above it.
What this error means
A syntax error points at a token (often the start of the next statement or a class brace) and complains a semicolon was expected before it.
clang
point.h:5:1: error: expected ';' after class definition
5 | }
| ^
| ;Common causes
How to fix it
Add the missing semicolon
- Look at the line above the reported location, not just the line cited.
- Class and struct definitions in C++ must end with a semicolon after the closing brace.
clang
struct Point {
int x;
int y;
}; // <- this semicolon is requiredHow to prevent it
- Terminate every class/struct definition with a semicolon and read the diagnostic on the line above the one the compiler cites.
Related guides
gcc/clang "error: 'X' was not declared in this scope" in CIFix gcc/clang "error: 'X' was not declared in this scope" in CI - the name is unknown at that point because a…
gcc/clang "error: ISO C++ forbids ..." in CIFix gcc/clang "error: ISO C++ forbids ..." in CI - a non-standard extension is rejected because the compiler…