# C++: error: expected primary-expression before ')' token

**Code:** `expected primary-expression before` · **Category:** C/C++ · **Seen on:** C/C++, GCC, Clang

The parser expected a value or expression and found a token that cannot start one — often a type name passed where a value belongs.

## Meaning

Typical triggers: passing a type to a function (`foo(int)`), an empty argument, a stray comma or `)`, or a macro that expands to nothing. GCC names the unexpected token in the message, so look at what precedes it.

## Common causes

- A type name used where a value is expected (for example `sizeof(x)` written as `size(int x)`)
- Missing argument between commas or before `)`
- Trailing comma in an argument or initializer list
- Macro that expands to an empty expression
- Mixing up declaration syntax and a function call

## Quick fix

1. Check the arguments of the call at the reported column
2. Remove stray commas and extra `)`
3. Pass a variable or literal, not a type

## Detailed fix by platform

### GCC / Clang

1. Expand macros to see the real code: `g++ -E main.cpp | less` and search near the reported line

## Code examples

### Type passed instead of a value

```cpp
int square(int n) { return n * n; }

int main() {
    // int r = square(int);          // error: expected primary-expression before 'int'
    int r = square(5);
    return r;
}
```

## How to diagnose

1. **Token** — Which token does the message name?
2. **Arguments** — Are all argument slots filled?
3. **Macros** — Does a macro expand to nothing?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/expected-primary-expression)
