Overload resolution with extern "C" linkage

Even if it was allowed by the standard, future maintainers of the code will probably be extremely confused and might even remove the extern "C", breaking the C code (possibly far enough later that the events aren't linkable).

Just write the wrapper.

EDIT: From C++03 7.5/5:

If two declarations of the same function or object specify different linkage specifications (that is, the linkage specifications of these declarations specify different string literals), the program is ill-formed if the declarations appear in the same translation unit, and the one definition rule (3.2) applies if the declarations appear in different translation units...

I interpret this to not apply since C and C++ functions with the same name aren't actually the same function but this interpretation may be wrong.

Then from C++03 7.5/6:

At most one function with a particular name can have C language linkage...

This then implies that you could have other, non-C-linkage, functions with the same name. In this case, C++ overloads.


I believe the language in the standard is specifically written to allow exactly one function with "C" linkage, and an arbitrary number of other functions with "C++" linkage that overload the same name (§[dcl.link]/6):

At most one function with a particular name can have C language linkage. Two declarations for a function with C language linkage with the same function name (ignoring the namespace names that qualify it) that appear in different namespace scopes refer to the same function. Two declarations for an object with C language linkage with the same name (ignoring the namespace names that qualify it) that appear in different namespace scopes refer to the same object.

The standard shows the following example:

complex sqrt(complex); // C + + linkage by default
extern "C" {
    double sqrt(double); // C linkage
}

Tags:

C++

C

Overloading