extern [C++ Reference]
Keywords: keywords,extern
Date: 2008-10-30T10:36:47-0700

[[extern]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## 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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •