Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!adam.pika.mit.edu!scs From: scs@adam.pika.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: Prototyping char parameters in ANSI C Message-ID: <10937@bloom-beacon.MIT.EDU> Date: 29 Apr 89 03:04:28 GMT References: <3950014@eecs.nwu.edu> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 43 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: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? Poor GNU! They get asked this ALL THE TIME, they put in a three line warning/explanation message, and people still don't get the idea. To recap, either use void f(int); void f(char); or void f(c) void f(char c) char c; {} {} The only difference is that the second form may allow the argument not to be widened when passed, for those architectures which support passing sub-word sized arguments. (In either case, c will act like a char within function f, being narrowed if necessary, and having its effective address adjusted so that something like f(c) char c; { write(1, &c, 1); } works correctly on big-endian architectures. Don't write that, though; write(,,1) brings a machine to its knees.) Steve Summit scs@adam.pika.mit.edu