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.
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