Impact of the use of extern & ldquo; C & rdquo; {On C ++ code when using g ++

advertisements

When using G++ (e.g. version 4.5 on Linux) can anyone explain what will/can happen if a user writes a header file for a mixed C/C++ system like this:

#ifdef __cplusplus 

extern "C" {

int myCPPfunc(some_arg_list....); /* a C++ function */

}
#endif

but here myCPPfunc() is a normal C++ function with a class def inside - i.e. it was wrongly labeled as a C function.

What is the impact of this?


The main impact of this is that you cannot overload it, e.g. this is legal:

int myCPPfunc(int a);
int myCPPfunc(char a);

But this is not:

extern "C"
{
    int myCPPfunc(int a);
    int myCPPfunc(char a);
}