I am learning storage classes in C.I have a simple code 

```
enter code here
int f1()
{
    static int i=0;
    i++;
    printf("%d",i);
}

int f2()
{
    printf("%d",i);
}

int main()
{
    f1();f2();f1();f2();
}

```

Compiler gives error as 'i' is undeclared in f2().
As I thought,memory static variables are allocated in data section of program memory.So any function in that file should be able to access it.

How does compiler knows that variable locally declared in function is bounded to that function only?How compiler evaluates that?