1. The function of extern "C" is used to tell the compiler that the function is written in C language.
Ii. Use the following methods:
1. extern "C" Void exit (INT) // containsC LanguageThe exit function.
2. extern "C"
{
Int printf (const char *....);
Int scanf (char *...);
....
} // Contains a group of functions written in C language.
3. extern "C" {# include <cmath>} contains functions in the Standard C library.
Iii. Supplement
1. extern can be placed before the variable Declaration; 2. extern can also be placed before the function declaration; through this behavior, it tells the compiler that the definition of the variable/function already exists somewhere, let the compiler look for its definition in other modules. 3. extern "C" uses extern "C" mainly because the C ++ language implements polymorphism during compilation, function names and functions are combined to form another function name (in short, the compiled function name is different from the one you previously declared ), the concept of no polymorphism in C Language certainly does not have this strange name change problem. This is the problem. When you want to call the C function in C ++, because of the different names, it will not find the definition of the called function, therefore, an error occurs. To solve the conflicts between C and C ++, the extern "C" extern exists ".