Skip to content
Latchkey

gcc/clang "expected primary-expression before" in CI

The compiler reached a point where an expression was required but found something that cannot start one - often a type name used where a value was expected, or a missing operand.

What this error means

A parse error reports "expected primary-expression before" a token such as a type name, > or ), frequently after a template syntax or missing-argument mistake.

gcc
app.cpp:6:18: error: expected primary-expression before '>' token
    6 |   auto v = make<int>();
      |                  ^

Common causes

How to fix it

Supply a valid expression

  1. Replace the type with a value, or fix the missing operand.
  2. For dependent template calls, add the template disambiguator.
gcc
obj.template make<int>();   // template keyword for dependent name

How to prevent it

  • Use values (not bare type names) where expressions are required and add the template keyword for dependent member templates.

Frequently asked questions

What causes ""expected primary-expression before""?
A parse error reports "expected primary-expression before" a token such as a type name, > or ), frequently after a template syntax or missing-argument mistake.
How do I fix "expected primary-expression before"?
Supply a valid expression

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card