# C++: error: no matching function for call to 'f(int, const char*)'

**Code:** `no matching function for call to` · **Category:** C/C++ · **Seen on:** C/C++, GCC, Clang

No overload of the function accepts the arguments you passed — wrong count, wrong types, or a missing conversion.

## Meaning

GCC lists every candidate and why it was rejected ("candidate expects 2 arguments, 1 provided", "no known conversion from ..."). Read the first candidate that looks like what you meant. For constructors the message says `no matching function for call to 'X::X(...)'`.

## Common causes

- Wrong number of arguments
- Argument type has no implicit conversion to the parameter type
- Passing a temporary to a non-const reference parameter
- Template deduction failed because arguments disagree (for example int and double)
- Function declared in a different namespace or not yet declared

## Quick fix

1. Compare your call with the first "candidate:" line
2. Convert explicitly (`static_cast`) or change the parameter type
3. Make reference parameters `const T&` when passing temporaries

## Detailed fix by platform

### GCC / Clang

1. Add `-fdiagnostics-show-template-tree` for long template messages, or read only the first note under each candidate

### C++

1. Match the signature exactly or add an overload; for constructors check member-initialisation order and braces

## Code examples

### Temporary cannot bind to a non-const reference

```cpp
void scale(double& factor);          // takes a non-const reference

int main() {
    // scale(2.0);                   // error: no matching function (cannot bind rvalue)
    double f = 2.0;
    scale(f);                        // OK
}
// or declare: void scale(const double& factor);
```

## How to diagnose

1. **Count** — Same number of arguments as the candidate?
2. **Types** — Which "no known conversion" line applies?
3. **Reference** — Is a temporary passed to T&?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/no-matching-function-for-call)
