Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!bloom-beacon!usc!orion.cf.uci.edu!uci-ics!zola.ics.uci.edu!schmidt From: schmidt@zola.ics.uci.edu (Doug Schmidt) Newsgroups: comp.lang.c Subject: Re: Prototyping char parameters in ANSI C Message-ID: <12754@paris.ics.uci.edu> Date: 26 Apr 89 23:58:29 GMT References: <3950014@eecs.nwu.edu> Sender: news@paris.ics.uci.edu Reply-To: Doug Schmidt Organization: University of California at Irvine: ICS Dept. Lines: 46 In article <3950014@eecs.nwu.edu> gore@eecs.nwu.edu (Jacob Gore) writes: ++ Is this valid ANSI C (or dpANS or whatever you want to call it): ++ ++ void f(char); ++ ++ void f(c) ++ char c; ++ { ++ } ++ ++ The version of GNU cc I have complains: ++ ++ t.c: In function f: ++ t.c:5: argument `c' doesn't match function prototype ++ t.c:5: a formal parameter type that promotes to `int' ++ t.c:5: can match only `int' in the prototype ++ ++ Is this rule for real, or is this just a gcc bug? This is a real rule. Read the GNU C documentation: ---------------------------------------- Users often think it is a bug when GNU CC reports an error for code like this: int foo (short); int foo (x) short x; { } The error message is correct: this code really is erroneous, because the old-style non-prototype definition passes subword integers in their promoted types. In other words, the argument is really an int, not a short. The correct prototype is this: int foo (int); ---------------------------------------- Doug -- On a clear day, under blue skies, there is no need to seek. And asking about Buddha +------------------------+ Is like proclaiming innocence, | schmidt@ics.uci.edu | With loot in your pocket. | office: (714) 856-4043 |