1, suffix name: C++/c program header file with. h as the suffix, c program source file with. C as the suffix, C + + program source files are usually suffix. cpp (some books introduce some systems with a. cc or. cxx as a suffix of source files).
In the Linux system, GCC,. C (partial),. cc OR. cxx the source file for the suffix,
They are also C + + source code files.
2.extern keyword: extern can be placed before a variable or function to indicate the definition of a variable or function in another file, prompting the compiler to find its definition in other modules when it encounters this variable and function. Additionally, extern can be used for link designation.
Which means that extern has two functions, the first one, when it is used with "C", such as: extern "C" void fun (int a, int b), tells the compiler to compile fun this function name, according to the rules of C to translate the corresponding function name rather than C + +, C + + In translating this function name, the fun name will become unrecognizable, possibly
fun@abc_int_int#%$ may also be something else, depending on the "temper" of the compiler (different compilers use the same method)
Second, when extern does not modify a variable or function together with "C", as in a header file: extern int g_int; Its role is to declare the function or global variables of the scope of the keyword, its declared functions and variables can be used in this module live other modules, remember it is a declaration is not defined! That is, if the B module (the compilation unit) refers to a global variable or function defined in the module (compile unit) A, It only contains the header file of a module, in the Compile phase, Module B can not find the function or variable, but it will not error, it will be in the connection from module a generated from the target code to find this function.
The above C language and C + + basic knowledge point (Must SEE) is small to share all the content of everyone, hope to give you a reference, but also hope that we support cloud habitat community.