Hi,
I learned that C compiler converts a function's prototype/definition to a binary format by the function name Only,
while C++ compiler converts a function's prototype/ definition to a binary format by its function name + arguments types/quantity. (that's why functions overloading is feasible in C++)
Then, it was said that to enable calling C compiled function from C++ code, one should use the extern "C" directive.
What does it mean?
why can't C++ compiler just compile all these function in both CPP and C source files?
Or is the above talking on a case where C++ Compiler is given C Object files, and not C Source files.
for example, when I write this function, without using extern "C" on printf(..), I don't get linkage error.
How come?
(I use Visual Studio C++ Compiler)
1 2 3 4 5 6 7
|
#include <stdio.h>
int main()
{
printf("hello, is it me you're looking for");
return 0;
}
|