Skip to content
Latchkey

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

  1. Look at the line above the reported location, not just the line cited.
  2. 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 required

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →