Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!hc!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: C linkage query Message-ID: <1795@auspex.auspex.com> Date: 9 Jun 89 17:45:32 GMT References: <9449@alice.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 41 >I'm not sure what you are asking, I think he's asking "does anyone have a C compiler + linker incapable of handling the given example?" (in fact, that's what he did ask!) A bit of (possible) background: The C compilers that I've used - all UNIX ones - will not blithely generate code that causes a symbol table entry to be made for symbols to which no reference is made. I.e., the mere *appearance* of the line extern int foo; in a program will not change the generated object file. The question was whether there *is* a compiler in which the mere appearance of a line like: extern int foo; in a file that contains no references to the "foo" declared by that line will cause the object file generated by that compiler (we assume here that the compiler *does* generate object files, which are to be linked by a linker - as indicated by "C compiler + linker") to contain an external reference to "foo" in its symbol table, such that said external reference *must* be satisfied in order to successfully link that object file into an executable image. I.e., if you compile a file containing extern int foo; main() {} and link that *with no other object files and with no libraries that define "foo"*, will the link fail? Several people have given examples where it *doesn't* fail, but I don't know that those are interesting in this case; the existence of 1 million compiler/linker pairs in which it doesn't fail doesn't demonstrate that no compiler/linker pair exists in which it *does* fail.