Peter Bex scripsit:

> Does this mean an unsigned char argument to a varags function is always
> widened to "int"?  How else can it know how much to take off the stack?

Yes, it does.  This pattern is called "the integer promotions" in the C
standards: _Bool, short, char, bitfield, and enum types are automatically
promoted to int, or if int is too small, to unsigned int, whenever (a)
they are used in an expression, or (b) passed as a function argument
and there is no function prototype in scope (which there cannot be for
varargs arguments).  Basically, C does not deal with types narrower than
int unless a function prototype forces it to.

> And if it really is the case that characters are always widened to
> integers, why bother to have a %c format specifier in the first place?

The %c format specifier converts its input to a character and outputs that
character.  There is no other format specifier that does this.

-- 
John Cowan          http://www.ccil.org/~cowan        co...@ccil.org
Where the wombat has walked, it will inevitably walk again.
   (even through brick walls!)

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to