extern

From RAD Studio
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Storage Class Specifiers (C++)

Syntax

extern <data definition> ;
[extern] <function prototype> ;

Description

Use the extern modifier to indicate that the actual storage and initial value of a variable, or body of a function, is defined in a separate source code module. Functions declared with extern are visible throughout all source files in a program, unless you redefine the function as static.

The keyword extern is optional for a function prototype.

Use extern "C" to prevent function names from being mangled in C++ programs.

Also, extern templates allow you to define templates that are not instantiated in a translation unit. Using extern templates thus reduces both compilation time and the size of the compiled module. The extern template feature is part of the new C++11 standard.