Re: Printf question.



praeiji <spacecaps@xxxxxxxxx> wrote:

> But why are they typecasted to int? Does it come from gcc when it sees
> "%d" and the printf function?

No, they are not typecasted, but `promoted', which is not the same thing.
Promotion is what happens when you call a function that has no prototype, or
when a function with a variable number (variadic) of arguments like printf()
is called. With promotion, all arguments are converted to a generic 'bigger'
type: char and short to int, float to double.

Ico

--
:wq
^X^Cy^K^X^C^C^C^C
.



Relevant Pages

  • Re: promotion of integer types
    ... > After multiplying the unsigned int result is: ... promotion. ... for GCC (the standard doesn't say what ... With educated guesses of the ranges of the types in both compilers, ...
    (comp.lang.c)
  • Re: Printf question.
    ... But why are they typecasted to int? ... Does it come from gcc when it sees ... "%d" and the printf function? ... Prev by Date: ...
    (comp.lang.c)
  • Re: unsigned short addition/subtraction overflow
    ... short _are_ representable as an int. ... operands, ... A cast will not _override_ integral promotion. ... implementing unsigned integer types as a whole, ...
    (comp.lang.c)
  • Re: Variable Argument Functions
    ... Papastefanos Serafeim wrote: ... char is promoted to Int. ... promotion is possible. ... look at case float case, author have used double for the case of float. ...
    (comp.lang.c)
  • Re: Expression evaluation using __int64
    ... The inputs to the offset calculation are all unsigned shorts or ... promotion is guaranteed to be the same as the value before the ... promoted to type int if int can represent the full range of the ... Casting either of the multiplicands as you've shown will guarantee ...
    (microsoft.public.dotnet.languages.vc)