extern

The extern keyword is used to inform the compiler about variables declared outside of the current scope. Variables described by extern statements will not have any space allocated for them, as they should be properly defined elsewhere.

Extern statements are frequently used to allow data to span the scope of multiple files.

When applied to function declarations, the additional ā€œCā€ or ā€œC++ā€ string literal will change name mangling when compiling under the opposite language. That is,

extern "C" int plain_c_func(int param);

allows C++ code to execute a C library function plain_c_func.

See also: extern "LANG" Linkage Issues