Xref: utzoo comp.unix.wizards:23577 comp.lang.c:31311 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!clyde.concordia.ca!mcgill-vision!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.unix.wizards,comp.lang.c Subject: Re: OK, so why _does_ ld resolve text against data? Message-ID: <17489@haddock.ima.isc.com> Date: 23 Aug 90 03:04:23 GMT References: <1990Jul30.104726.22660@mtcchi.uucp> <37909@ucbvax.BERKELEY.EDU> <930@eplunix.UUCP> Reply-To: karl@kelp.ima.isc.com (Karl Heuer) Followup-To: comp.lang.c Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 42 In article <930@eplunix.UUCP> das@eplunix.UUCP (David Steffens) writes: >1> ... "lint" does identify the problem ... >Only if the "problem" appears in _source code_ which can be linted. Anything that isn't visible in lintable source code (e.g. a vendor's library) ought to have a corresponding lint library already built. (Not all do, but then this is the vendor's bug.) >int index; >main() { > vendor_library_routine(); /* which, unknown to me, uses index() */ >} >Even if the vendor provides a lint library, "lint" is no help at all! Oh? Let's try it. (Quick switch to a BSD system...) $ cat bug.c int index; int main() { return 0; } $ lint bug.c bug.c: index value declared inconsistently llib-lc(272) :: bug.c(1) $ Perhaps you mean systems on which `index' is not a documented interface, but where a library happens to have a helper function with that name? In that case, the vendor is at fault for failing to declare it static. >Is every programmer supposed to memorize the name of every libc routine just >to avoid picking one by accident? If you replace `every libc routine' with `every symbol reserved by the standard to which the program attempts to conform', then I'd say Yes, it's a good idea. For those whose memory is less than perfect (or who don't have a copy of the relevant standard), we have tools like lint. >No sir. In my view the linker is seriously deficient here. I'll agree with the point that a type-checking linker would be a good thing. It would probably slow down the linking pass, but I'd still use it if I had it. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint Followups to comp.lang.c only.