E25 Answer


The separate files will each compile without problem. But the linker will abort, and no executable will be created.

fileA.c asks for an object x to be initialized to 8 before the program starts running (and so does the object file fileA.o.) But fileC.c asks for the same object x to be initialized to 77 before the program starts running (and so does the object file fileC.o.) The linker can't initialize one object to two values, and so will not create an executable.


/* --- fileA.c --- */
int x = 8


/* --- fileB.c --- */ foo() { extern int x; x = 99; }
/* --- fileC.c --- */ int x = 77; main() { foo(); printf("%d\n", x ); system("pause"); }