Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: The free() thing and function names Message-ID: <1989Sep15.183248.2955@utzoo.uucp> Organization: U of Toronto Zoology References: <1989Sep14.022055.5961@twwells.com> <841@uniol.UUCP> Date: Fri, 15 Sep 89 18:32:48 GMT In article <841@uniol.UUCP> lehners@uniol.UUCP (Joerg Lehners) writes: >What does the standard say about standardized function overriding ? The answer is a little complicated. Assuming you just want to use a standard function's name for your own purposes, you can always do this provided (a) it doesn't begin with __ or _[A-Z], and (b) you do not #include the standard header declaring that function. If either of these restrictions is violated, behavior is "undefined", i.e. it's up to your compiler and it's not portable. If what you want is to supply, say, your own atof() function, *and* have [say] scanf() use it, there is no portable way to do this. ANSI C essentially demands that scanf() not call atof() at all, but some internal version with a name in the implementation-reserved name space (see clause (a) above). This is so you can innocently re-use the name, as above, without breaking scanf(). Your compiler *might* permit you to override the function scanf() is using, but the name will be implementation-specific and the overriding will violate clause (a) above. > a.) C-Compiler: just the C keywords are reserved, > function overriding possible and possible more. > b.) C-System (C-Compiler plus standardized function package [often > called 'library']: C keywords reserved; return type, argument types > of standardized functions reserved; and more. It is not necessarily possible for an implementation to make a clean split between the two, since some of the standard functions may be wired into the compiler. ANSI C does permit that, subject to the requirement that the relevant headers be #included, so that innocent name re-use is not an issue. X3J11 was not at all keen on having multiple versions of C, so it generally didn't provide the sort of choice you suggest. (It did end up being talked into providing one choice, between "hosted" and "free-standing" implementations, which has some similarity to your request but isn't the same thing.) -- V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology 1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu