file1.c:
int x; /* a declaration, and also a definition, external linkage */
static int y; /* a declaration, and also a definition, internal linkage */
int z; /* see declaration in file2.c */
void f1( void ); /* a declaration, and also a function prototype, defined in file2.c */
int main( void ) {
x++; /* x incremented from 0 to 1 */
f1(); /* x incremented from 1 to 2 */
}
file2.c:
int x; /* a declaration, and also a definition, external linkage, same variable as x in file1.c */
static int y; /* a declaration, and also a definition, internal linkage, totally separate from y in file1.c */
extern int z; /* a declaration, defined in file1.c */
void f( void ) {
x++;
}
Notes: