Storage Class and Scope

Scope

Storage Class Declaration vs Definition

Scope
Global Object Lexical Scope Local Object Lexical Scope
Storage Class Uninitialized Value Global to Entire Application Local to Source File Local to Block
Static Set to 0
/* static and global declared */
extern int var;

/* static and global defined */
int var;
/* static and local to a file */
static int var;
/* static and local */
void func(void)
{
    static int var;
}
Automatic UNDEFINED
/* automatic and local */
void func(void)
{
    int var;
}

Other Lexical Scopes

Next slide