Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!watmath!rbutterworth From: rbutterworth@watmath.UUCP (Ray Butterworth) Newsgroups: comp.lang.c Subject: Re: Reserved words in C Message-ID: <4207@watmath.UUCP> Date: Tue, 6-Jan-87 12:45:44 EST Article-I.D.: watmath.4207 Posted: Tue Jan 6 12:45:44 1987 Date-Received: Wed, 7-Jan-87 00:46:31 EST References: <1524@hoptoad.uucp> <1016@zeus.UUCP> <5476@brl-smoke.ARPA> Organization: U of Waterloo, Ontario Lines: 34 In article <5476@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > I'm not sure that's what X3J11 intended, but it's what I deduce > from section 1.6 of the Draft Proposed Standard; however, one > wonders why "additional library functions" are mentioned if > they would be so hard to provide (basically, there would have > to be a header file that redefined the externs as _-names). The solution used by the C (and B and Pascal) library maintained here is to have two names for every external (trivial when the source is in assembler, possibly more difficult if it's in C (maybe that would be a good use for the "entry" keyword?)). All library functions that call other library functions do so by their "other" name. Thus a user program could define functions called printf() or write(), while any library functions that need the standard printf or write for error messages will still get the standard version, not the user's. printf is rather obvious and not likely to be accidentally redefined by a user; there are other names that aren't so obvious (e.g. BSD's index), and such a scheme prevents accidents. If a user really wants to redefine a library function, he can use its alternate internal name. It would have been nice if ANSI had required some such scheme. It would also have been nice if ANSI had defined its standard library following its own reserved name rule (i.e. a leading underscore). For instance the stdio functions would have been _printf(), _putchar(), etc. For compatibility with existing implementations aor or or whatever could have been provided with appropriate defines to map the names or even the calling sequences. This would also solve the problem of names such as isascii() being reserved but undefined. Any library that now uses or defines isascii() is in violation of the standard.