Extern variables question
John Hascall
hascall at atanasoff.cs.iastate.edu
Thu Nov 16 12:49:25 AEST 1989
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
More information about the Comp.lang.c
mailing list