A variable declared globally is said to having program scope
A variable declared globally with static keyword is said to have file scope.
For example:
int x = 0; // **program scope**
static int y = 0; // **file scope**
static float z = 0.0; // **file scope**
int main()
{
int i; /* block scope */
/* .
.
.
*/
return 0;
}
What is the difference between these two?
x has a file scope which terminates at the end of translation unit
(which means it is visible only in this unit) andx can is [be] accessible to other translation unit
is technically correct but may be a bit confusing. (Nonetheless I found the wiki page en.wikipedia.org/wiki/Linkage_(software) to be equally confusing. The thing is that being ``accessible" and visible are not the same. – Hirundine