Func Protos with K&R Func Defs
Chris Torek
torek at elf.ee.lbl.gov
Thu Mar 7 13:42:34 AEST 1991
In article <BPX9AT9 at xds13.ferranti.com> peter at ficc.ferranti.com
(Peter da Silva) writes:
>So you're saying that the compiler is not allowed to take advantage of the
>prototype information and use (for example) callee saves or special LINK
>instructions when calling prototyped functions?
This statement is correct (in a strict logical sense), but all the
implications it makes are wrong. That is, the statement
[compiler treats prototyped functions specially] implies
[compiler may not take advantage of...]
is true but only because the clause [compiler treats prototyped
functions specially] is false. Aside from default promotions,
prototyped functions and non-prototyped functions are treated
identically. In particular, the compiler make take advantage of
special LINK or RET instructions for non-prototyped functions as
well as for the prototyped versions.
The only special case is varargs functions, which *must* be declared
using the new prototype varargs syntax. All other functions may be
assumed to take fixed argument lists. In other words,
f(fmt, a1, a2, a3, a4, a5) char *fmt; {
printf(fmt, a1, a2, a3, a4, a5);
}
...
f("%d\n", 3);
is illegal, because the caller did not supply the proper number and
type of arguments.
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427)
Berkeley, CA Domain: torek at ee.lbl.gov
More information about the Comp.lang.c
mailing list