Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!atanasoff!atanasoff.cs.iastate.edu!hascall From: hascall@atanasoff.cs.iastate.edu (John Hascall) Newsgroups: comp.lang.c Subject: Extern variables question Keywords: extern , variable , allocation Message-ID: <1958@atanasoff.cs.iastate.edu> Date: 16 Nov 89 01:49:25 GMT Sender: hascall@atanasoff.cs.iastate.edu Reply-To: hascall@atanasoff.cs.iastate.edu (John Hascall) Distribution: na Organization: Iowa State Univ. Computation Center Lines: 26 I have been involved in a ``discussion'' over which (if any) of the four following pairs of modules are identical in result. Assume that in each case the two modules are compiled separately and linked with: int main(int argc, char **argv) { void foo(void); void bar(void); foo(); bar(); return(1); } module1.c module2.c ------------------- ------------------- (a) int i; int i; void foo(void) {} void bar(void) {} (b) extern int i; int i; void foo(void) {} void bar(void) {} (c) extern int i; int i = 0; void foo(void) {} void bar(void) {} (d) extern int i; extern int i; void foo(void) {} void bar(void) {} What is the answer and WHY? Thanks, John