Table 2: Linkage and storage duration for objects based on storage
class
specifier and scope
Storage Class Specifier | At Namespace Scope | at Class Scope | at Block Scope |
---|---|---|---|
none | internal linkage if const, external otherwise; static storage | no linkage; storage allocated as part of enclosing object | same as auto |
auto | - | - | no linkage automatic storage |
extern | external linkage unless previously declared with internal linkage; static storage | - | external linkage unless previously declared with internal linkage in an enclosing scope; static storage |
register | - | - | same as auto |
static | internal linkage; static storage | external linkage; static storage | no linkage; static storage |
Note: An empty entry indicates an invalid combination of scope and storage class specifiers. |