Prototyping char parameters in ANSI C
Doug Schmidt
schmidt at zola.ics.uci.edu
Thu Apr 27 09:58:29 AEST 1989
In article <3950014 at eecs.nwu.edu> gore at 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 at ics.uci.edu |
With loot in your pocket. | office: (714) 856-4043 |
More information about the Comp.lang.c
mailing list