From: "David Thompson" <david.thompson1@worldnet.att.net>
Subject: Re: Another ammunition
Date: Sat, 04 Jan 2003 20:17:31 GMT
Date: 2003-01-04T20:17:31+00:00 [thread overview]
Message-ID: <vjHR9.27734$p_6.2299935@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: 3E11C888.1060102@cogeco.ca
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1963 bytes --]
Warren W. Gay VE3WWG <ve3wwg@cogeco.ca> wrote :
> Jean-Pierre Rosen wrote:
> > "Eric G. Miller" <egm2.NOSPAM@jps-NOSPAM.net> a �crit dans le message news:
IpfQ9.4953
...
> >>You're right, but I'm sure gcc could have immediately diagnosed the
> >>problem had you turned up the warnings ("conflicting types for...",
"previous
> >>declaration of ...").
> >
> > Warnings were on, he just overlooked them....
Could have (and did) *IF* the same declaration is visible at
all relevant locations, typically by #include'ing the same .h file.
If you just write out a wrong declaration of foo in bar.c, gcc can't
catch it (though a good lint can). Also, if you mistakenly #include
a wrong .h file (such as from a wrong subtree) gcc can't catch it,
although this is unlikely in simple student projects.
(A C implementation *could* legally and practially do
the kinds of whole-program or at least cross-unit checks
Ada requires and GNAT does, but they don't, not even gcc.)
...
> Things may be different now, but I once had a long email discussion
> with one of the folks about whether a missing return "type" should
> be a warning or not (it should actually be an error). At the time,
> you had to specify a compile option to make a declaration like:
>
> foo() { ... }
>
> return a warning. ...
(That's a definition, not just a declaration.
/*int*/ foo () ; is a typical "external" declaration.)
According to all C standards before C99 (K&R and C89) it *is*
legal and so can't conformingly be an error. With C99 it is a
required diagnostic and could well be an error, but won't because
implementors don't want to break vast masses of existing legal
and supported code. I agree it should be a warning, but whether
it's on by default doesn't matter much to me, since I always end up
with some mechanism (makefile, script, envvar) for setting flags
anyway, and if this needs an entry in there it's no real trouble.
--
- David.Thompson 1 now at worldnet.att.net
next prev parent reply other threads:[~2003-01-04 20:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-31 10:23 Another ammunition Jean-Pierre Rosen
2002-12-31 11:43 ` Eric G. Miller
2002-12-31 12:57 ` Jean-Pierre Rosen
2002-12-31 16:23 ` Alexander Schreiber
2003-01-02 6:55 ` AG
2003-01-01 16:58 ` Alexander Schreiber
2003-01-07 12:54 ` Peter Hermann
2003-01-07 13:21 ` Richard Riehle
2003-01-11 18:29 ` Alexander Schreiber
2003-01-13 2:11 ` u.r. faust
2003-01-12 12:44 ` Larry Kilgallen
2003-01-14 1:24 ` Georg Bauhaus
2003-01-03 9:50 ` Jean-Pierre Rosen
2003-01-03 15:24 ` Stephen Leake
2002-12-31 16:40 ` Warren W. Gay VE3WWG
2003-01-04 20:17 ` David Thompson [this message]
2003-01-06 17:39 ` Warren W. Gay VE3WWG
2003-01-06 20:50 ` Stephen Leake
2003-01-06 22:16 ` Warren W. Gay VE3WWG
2003-01-07 18:37 ` Stephen Leake
2003-01-07 21:55 ` Warren W. Gay VE3WWG
2003-01-01 9:05 ` Michael Erdmann
2003-01-07 13:03 ` Peter Hermann
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox