🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1637

Re: May prototypes be required for lib functs

#1637
From: David Brooks
Date: Fri, 07 Sep 1990 15:45
43 lines
2641 bytes
(this followup adds comp.lang.c to comp.std.c)
In article <13759@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:

|> Furthermore, any function need not be declared using prototype ("new-
|> style") syntax if its parameters have already-default-widened types
|> (as I think all the standard library functions do).  And any function
|> need not be declared at all if it returns type int and its parameters
|> have already-default-widened types.

This loses some of the benefits of prototypes.  But if your parameters
don't have already-widened types, you must beware of the following
situations:

Define your callee with a narrow parameter or two, and accidentally
leave out the prototype from the caller.  Your program breaks.  We all
know this, right?  Not necessarily.

Build a library using prototypes and narrow parameters, and put the
binary out on the streets.  Your customers had better use prototypes
in their application code, which means you have to insist they build
with a prototyping compiler.  Reasonable.

It gets worse.  There are some overly-helpful compilers out there
which do the widening anyway, prototype or no.  This is quite
consistent with the ANSI rules; it works so long as the caller and
callee agree about it.  So you do all your program development with
that compiler, test it up the wazoo, and put the source out on the
streets.  But you got the prototypes mixed up - either you misspelt
the function name in a header file or you left a #include out of a
source.  A paying customer points a less-helpful compiler at it (or
the same compiler, built differently), and it breaks in obscure ways.

Of course, such a compiler would produce at least a comment when it
encounters a default-declared procedure.  But prudence is beginning to
suggest that I balance the advantages of decent parameter type
checking against handling non-reproducible-in-house parameter-passing
bugs.

(people who meet me in other newsgroups know what I'm talking about).
-- 
David Brooks				dbrooks@osf.org
Systems Engineering, OSF		uunet!osf.org!dbrooks
Experience Hackvergnuegen!
Technical Details
Message-ID: <1990Sep7.114544@osf.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!bu.edu!husc6!paperboy!osf.org!dbrooks
References: <478@hitachi.uucp> <13759@smoke.BRL.MIL>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!bu.edu!husc6!paperboy!osf.org!dbrooks
From: dbrooks@osf.org (David Brooks)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: May prototypes be required for lib functs
Message-ID: <1990Sep7.114544@osf.org>
Date: 7 Sep 90 15:45:44 GMT
References: <478@hitachi.uucp> <13759@smoke.BRL.MIL>
Sender: news@OSF.ORG
Reply-To: dbrooks@osf.org (David Brooks)
Organization: Open Software Foundation
Lines: 43