Re:New C features in GCC 13
by _kst_ on Thursday May 04, 2023 @08:23PM
(#35823895)
In the declaration
char letter = 'x';
the initialization expression 'x', which for historical reasons is of type int in C, is implicitly converted to the type of the object. `letter` is a `char` because you defined it that way.
If you had written
int letter = 'x';
that would be perfectly valid, and the conversion would be trivial (int to int).
It's just like:
double x = 42;
`sizeof 42` might be 4 (sizeof (int)), but `sizeof x` will be the same as `sizeof (double)` (perhaps 8).
If you had written
that would be perfectly valid, and the conversion would be trivial (int to int).It's just like:
`sizeof 42` might be 4 (sizeof (int)), but `sizeof x` will be the same as `sizeof (double)` (perhaps 8).