function prototype problem

Sean Fagan seanf at sco.COM
Mon Nov 14 08:55:13 AEST 1988


In article <310 at drd.UUCP> mark at drd.UUCP () writes:
[about the gcc problem with:]
>char *rpeet  ( short, char );
>char *rpeet ( num, ch )
>    short num;
>    char ch;
[where gcc will complain about num beind redeclared as an int]

gcc is behaving as if you had done a new-style declaration (since you
can have the 'int' as optional, you can declare 'int main(ac, char **av)'),
but had also predeclared it with a prototype.  I personally think that gcc
is wrong in this respect, but haven't had enough time lately to fix it.

The problem is that gcc "does not have infinite lookahead."  Stallman
maintains that ANSI says to expand the arguments to match the prototype, and
you are declaring rpeet (in the second one) as having to arguments of type
int.

I, however, maintain what what ANSI says is that, if you declare a function
using old-style declaration (as you did), then you do not expand the
arguments unless a prototype is given; but if you use newstyle declarations
(char *rpeet ( short num, char ch) {), everything is as if you had also
given a prototype.

Does anybody who knows the ANSI draft agree with me (Chris?  Dough?
Dennis?).  BTW, K&Rr2 warns about mixing old-style and new-style
declarations; it seems to be a good idea 8-).
-- 
Sean Eric Fagan  | "Engineering without management is *ART*"
seanf at sco.UUCP   |     Jeff Johnson (jeffj at sco)
(408) 458-1422   | Any opinions expressed are my own, not my employers'.



More information about the Comp.lang.c mailing list