Article View: comp.std.c
Article #1665Re: Parameter Types in Old-Style Function Definitions
From: Doug Gwyn
Date: Sun, 09 Sep 1990 21:15
Date: Sun, 09 Sep 1990 21:15
21 lines
1503 bytes
1503 bytes
In article <1990Sep8.053408.2005@alphalpha.com> nazgul@alphalpha.com (Kee Hinckley) writes:
>foo(c, i)
>char c;
>int i;
>{}
>extern foo(char c, int i);
These are not guaranteed to be compatible, since the definition uses
default-widened parameter types but the prototype declaration uses
unwidened (in general) types. Implementations that always default
widen arguments even for new-style functions linkage will probably
support this mixture, but other implementations will not.
The general coding rule for fixed-argument functions is:
EITHER always use already-default-widened parameter types
OR ELSE always use prototypes, never old-style declarations
or definitions
(For variable-argument functions, always use prototypes including ",..."
and use appropriate <stdarg.h> macros in the function definitions.)
If you try to mix old- and new-style syntax, you risk running afoul
of the genuine differences in linkage for the two styles.
Technical Details
Message-ID:
<13779@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwynReferences:
<10391@pt.cs.cmu.edu> <2689@dataio.Data-IO.COM> <1990Sep8.053408.2005@alphalpha.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Parameter Types in Old-Style Function Definitions Keywords: parameter, function Message-ID: <13779@smoke.BRL.MIL> Date: 9 Sep 90 21:15:10 GMT References: <10391@pt.cs.cmu.edu> <2689@dataio.Data-IO.COM> <1990Sep8.053408.2005@alphalpha.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21