static and global variable declaring
Generally, a global variable, int i, in file a.c can be use in file b.c by, extern int i. But, a static global variable, static int i, in file a.c can’t be used in any other file. So, if a global variable is declared static it can only be used in the file it exists.
How the C compiler work? If a global variable be declared, the compiler will use its name as a symbol. When other files declare extern by the same name, complier will find the symbol and reference this variable. If a static global variable be declared, the compiler will not create a symbol, it will only give this variable an address and all reference in the same file will be replced by this address. When other files declare extern varible by the same name, they can’t find the symbol and make declaring failure.
Thanks Frank offers the information.