Article View: comp.std.c
Article #2449Re: ANSI prototypes, the right choice...
From: Mike (My Watch Has Windows) Meye...
Date: Tue, 19 Feb 1991 23:10
Date: Tue, 19 Feb 1991 23:10
38 lines
2411 bytes
2411 bytes
In article <1205@teslab.lab.OZ> andrew@teslab.lab.OZ (Andrew Phillips) writes:
It depends on what you mean by "mixtures". If you mean using float,
short or char in prototypes and old style function definitions, ie:
double f(float x);
double f(x) float(x); { ... }
then this would be a big problem and I would expect any ANSI compiler
which found these in the same source file to generate an error. If
Lattice 5.10 does this then this is very bad, since the caller is
going to pass a float and the callee expects a double.
HOWEVER, I know that a lot of ANSI draft compilers, which had
prototypes but came out before the ANSI new style function
definitions were invented allowed this (but the caller would pass x
as a double so it was OK). Examples are older Lattice compilers
(4.0?)
Lattice (SAS) 5.10 accepts this. Note that it's billed as a "pre-ANSI"
compiler; the 5.1 release was an upgrade to add AmigaDOS 2.0 support,
not ANSI.
What this compiler does when it sees an old style definition that has
a prototype in scope is to see if the types were "compatable" (all of
them being identical before implicit promotions was), and if so
compile the function as if it were defined with the prototype style.
After all, the compiler had a prototype, and the function definition
agreed with it. Turns out this causes problems when you try and write
code that needs to port across multiple ANSI compilers and non-ansi
compilers.
<mike
--
Cats will be cats and cats will be cool Mike Meyer
Cats can be callous and cats can be cruel mwm@pa.dec.com
Cats will be cats, remember this words! decwrl!mwm
Cats will be cats and cats eat birds.
Technical Details
Message-ID:
<MWM.91Feb19171037@raven.pa.dec.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!bacchus!mwmReferences:
<7708@sugar.hackercorp.com> <15089@smoke.brl.mil> <1991Feb9.075215.26939@athena.mit.edu> <1991Feb11.030811.25074@sugar.hackercorp.com> <1205@teslab.lab.OZ>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!bacchus!mwm From: mwm@pa.dec.com (Mike (My Watch Has Windows) Meyer) Newsgroups: comp.std.c,comp.sys.amiga.programmer Subject: Re: ANSI prototypes, the right choice... Message-ID: <MWM.91Feb19171037@raven.pa.dec.com> Date: 19 Feb 91 23:10:37 GMT References: <7708@sugar.hackercorp.com> <15089@smoke.brl.mil> <1991Feb9.075215.26939@athena.mit.edu> <1991Feb11.030811.25074@sugar.hackercorp.com> <1205@teslab.lab.OZ> Sender: news@pa.dec.com (News) Organization: Missionaria Phonibalonica Lines: 38 In-Reply-To: andrew@teslab.lab.OZ's message of 19 Feb 91 06:38:05 GMT