|
|
extern is a data type modifier that tells the compiler about a variable that is defined elsewhere in the program. This is often used in conjunction with separately compiled files that share the same global data. In essence, it notifies the compiler about the type of a variable without redefining it. For example, if first were defined in another file as an integer, the following declaration would be used in subsequent files:
extern int first;
This declaration specifies first’s type, but storage for it has not been created.
For C++ only, extern is also used to create a linkage specification. It has this general form:
extern "language" function-prototype
Here, language denotes the language to which you want the function to link. C and C++ linkages are guaranteed to be supported. Your compiler may support other linkages, too. To declare several functions using the same linkage specification, you can use this general form:
extern "language" { function-prototypes }
|
|