I am trying to further understand the use of the keyword "static" for global variables. I know that if I declare a global variable as static, it will only be "visible" within the c file that it was declared in. I also understand that if I try to "extern" a variable declared as static in another file, it should not work.
extern int x; //shouldn't work
//extern static int x; //also shouldn't/wouldn't work
extern int y; //does work fine;
Here is what I don't understand: I have read on more than one website, that the default storage class for global variables is "static". If that is the case, why does "extern int y;" work in my example above? Granted, I want it to work the way it does, but if the default storage class IS static, how can it? I'm probably thinking about this too hard...
static int x;
NOTE: I am compiling on Ubuntu Linux using gcc. Also note, I am only refering to c, not c++.
Thanks for any clarification you can provide!