Question: I'm writing a c++ library that exposes some functions which are used only by C# code. However, as I accidently mistyped the paramter, I found that this code can be succesfully compiled and linked even without any warning as long as I don't use the (not mistyped version) function in the cpp file.

```
struct Dummy { int a; double b; };
extern "C" void SetArray(Dummy* x, int cnt);
void SetArray(Dummy x, int cnt)
{
    // a TODO placeholder.
}

```

How can I let compiler throw an error or a warning for this case? The compiler option -Wall is set but there's still no warning. Using tdmgcc 5.1.0.

Answer: 
You can make some assertion that will fail if function is overloaded:

```
static_assert(::std::is_same_v<void (Dummy *, int), decltype(SetArray)>);

```

> 
> error: decltype cannot resolve address of overloaded function
> 
> 
>
You can include `extern "C"` in the definition as well as the declaration.

```
struct Dummy { int a; double b; };
extern "C" void SetArray(Dummy* x, int cnt);
extern "C" void SetArray(Dummy x, int cnt)
{
    // a TODO placeholder.
}

```

Quentin's comment on VTT's answer was halfway there: it's not that C functions cannot be overloaded, it's that C functions cannot be overloaded with other C functions. The compiler will enforce this, but it can only do so if you explicitly specify you want a C function in both declarations.