Article View: comp.std.c
Article #3858Re: gets() and getchar
From: Richard A. O'Keefe
Date: Fri, 25 Aug 1995 10:00
Date: Fri, 25 Aug 1995 10:00
46 lines
2936 bytes
2936 bytes
clive@stdc.demon.co.uk (Clive D.W. Feather) writes:
>>>> cc .... -Dgets=DONT_USE_GETS
>You have missed the point. The Standard does not allow you to hide
>gets in this way, as Dan points out.
The standard is powerless to prevent it, because the form of expression
in question is not written in C. It's a Bourne shell, command! No-one
has ever claimed that this is a portable construct _in a C program_,
only that this is a useful debugging hack that happens to work on many
UNIX systems. The standard _doesn't_ say it is forbidden to do this,
or if it does, no-one has shown it yet. All it says is that
- a certain set of identifiers is reserved (cannot be used with
external linkage) under all circumstances
- if you include header so-and-so then certain identifiers are
reserved for all uses.
For example, if you #include <errno.h> and your program does strange and
twisted things because you used ERROR as an identifier, the standard
gives you no right to complain. However, the standard doesn't prohibit
some implementions letting you use that identifier even though it is
reserved.
My claim is
-- cc ... -Dgets=DONT_USE_GETS
is a technique which I picked up from some wizard on the net (sorry,
I forget who).
-- it does something which is partially outside the scope of the standard
(the standard has nothing to say about -D in general)
-- to the extent that the standard covers it, it involves doing something
which the standard warns against
-- but the standard does not prohibit some implementations doing something
useful with it
-- many UNIX implementations DO let it work, so
-- on THOSE implementations AT THE MOMENT (they could change tomorrow)
it is a useful technique for locating uses of a standard function
which is better avoided.
Let's face it, if I want to write a C compiler in which
putting -Dgets=DONT_USE_GETS in the command line says "forget about C,
this program is in PERL", the C standard can't stop me (common sense
would!), because the C standard has nothing to say about the external
interface to a C system.
--
"conventional orthography is ... a near optimal system for the
lexical representation of English words." Chomsky & Halle, S.P.E.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
Technical Details
Message-ID:
<41k6vv$ecd@goanna.cs.rmit.edu.au>Path:
arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mailReferences:
<Pine.ULT.3.91.950807194041.19202A-100000@mars> <40s0eo$k8c@goanna.cs.rmit.edu.au> <danpop.808655822@rscernix> <808736493snz@wbriscoe.demon.co.uk> <DDKuJq.84t@stdc.demon.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Newsgroups: comp.std.c Subject: Re: gets() and getchar Date: 25 Aug 1995 20:00:31 +1000 Organization: Comp Sci, RMIT, Melbourne, Australia Message-ID: <41k6vv$ecd@goanna.cs.rmit.edu.au> References: <Pine.ULT.3.91.950807194041.19202A-100000@mars> <40s0eo$k8c@goanna.cs.rmit.edu.au> <danpop.808655822@rscernix> <808736493snz@wbriscoe.demon.co.uk> <DDKuJq.84t@stdc.demon.co.uk> NNTP-Posting-Host: goanna.cs.rmit.edu.au NNTP-Posting-User: ok X-Newsreader: NN version 6.5.0 #0 (NOV)