Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!ncifcrf!kml From: kml@ncifcrf.gov (Kevin Lahey) Newsgroups: comp.lang.c Subject: Re: problem with cc compiler Summary: How to avoid name collisions with library functions? Message-ID: <1185@fcs280s.ncifcrf.gov> Date: 23 Jul 89 19:46:34 GMT References: <712@unsvax.NEVADA.EDU> <10589@smoke.BRL.MIL> Reply-To: kml@ncifcrf.gov (Kevin Lahey) Organization: NCI Supercomputer Center, Frederick, MD Lines: 34 In article <10589@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <712@unsvax.NEVADA.EDU> willey@arrakis.uucp (James P. Willey) says: >>... I finally realized that the function name "read" was the culprit. > >I assume that your problem was that getchar() eventually called read(), >expecting the version in the system's C library, but instead found one >you had written as part of your program. > >Standard-conforming C implementations are quite constrained in this >regard, and would not have invoked your read() function by mistake. Yow! Could you elaborate on this? I don't quite understand. Certainly, had he made a declaration: static read () { blah blah } then I could see how to avoid a collision. I just don't quite see how to insure that a regular function declaration doesn't override a library function. Assuming that this magic system works (I don't doubt that it does), how can one override a library function when desired? I made a brief perusal of the second edition of K & R, but I was not enlightened. Could you give me some pointers about where to look? Obviously, I'm not all up on the new ANSI-C stuff, but I want to be. Thanks, Kevin kml@fcs280s.ncifcrf.gov NCI Supercomputer Center, Frederick, Maryland kml@mosquito.cis.ufl.edu UF CIS Department, Gainesville, Florida Whenever you find that you are on the side of the majority, it is time to reform. -- Mark Twain