Arduino build error

error: expected primary-expression before ')' token

The compiler needed a value, a name or a number, and found a bracket, a comma or a keyword instead.

  • 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:5:15: error: expected primary-expression before ')' token
    5 |   if (total > ) {
      |               ^
exit status 1

It happens when an operand is missing, when a type is written inside a call, or when a variable is left out of a condition.

Mokxi's compiler, clang, words it as expected expression.

Causes

The 3 usual causes with the fix

1A value is missing next to an operator

A comparison or a sum needs something on both sides. An empty side leaves the compiler with nothing to read.

Broken
void setup() {
  Serial.begin(9600);
  int total = 3;
  if (total > ) {
    Serial.println("big");
  }
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int total = 3;
  if (total > 2) {
    Serial.println("big");
  }
}

void loop() {
}

Mokxi’s build tab says: Something is missing here: a value, a bracket or a name

Try this fix in Mokxi

2A type is written inside a function call

A call takes values, not declarations. int 13 in the brackets is a type where a number belongs.

Broken
void setup() {
  Serial.begin(9600);
  pinMode(int 13, OUTPUT);
  Serial.println("ok");
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  Serial.println("ok");
}

void loop() {
}

Try this fix in Mokxi

3A comma with nothing before it

A stray or doubled comma leaves an argument empty.

Broken
void setup() {
  Serial.begin(9600);
  int x = max(, 5);
  Serial.println(x);
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int x = max(2, 5);
  Serial.println(x);
}

void loop() {
}

Try this fix in Mokxi

FAQ

Questions and answers

What is a primary-expression?

The smallest piece of a calculation: a name, a number or a bracketed expression. The compiler found something else where one was needed.

Why does it say before a token?

The token named is the first thing the compiler could not use. The missing value sits just before it.

Is this the same as a missing semicolon?

No. A missing semicolon gives "expected ';'". This error means a value is missing inside a statement.