Prototyping char parameters in ANSI C
Lloyd Kremer
kremer at cs.odu.edu
Fri Apr 28 01:35:46 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
The responses I have seen all make reference to "old style" automatic widening
of the function argument to an int. The fact that the original poster
specified ANSI C suggests that he knows about the "old style" rules.
In any case I know I do. :-) But I thought that in the new ANSI C (not old--
NEW!) you could effectively circumvent this behavior and request that small
types be received by the called function as a true char (or float, or
whatever), size and all. There may still be temporary internal promotion due
to hardware characteristics such as the inability to push a single byte onto
the stack, but this should be transparent to the programmer.
So, I shall now ask: How do you tell the compiler that you want this *NEW*
behavior? If a full prototype isn't good enough, what is?
--
Lloyd Kremer
Brooks Financial Systems
...!uunet!xanth!brooks!lloyd
Have terminal...will hack!
More information about the Comp.lang.c
mailing list