Mail Archives: djgpp/1997/10/28/03:42:09
On Mon, 27 Oct 1997, Georg Kolling wrote:
> Using exactly this code, the compiler should give you the warning
> "multi-character character constant" because of "'\xFD'".
> '\xFD' represented as a number is 796411460, which can never be represented
> with an unsigned char.
I think you are wrong. 'c' constants are not character constants,
they are ints. You can verify it with a simple test program I attach
at the end of this message. It prints 4 for the sizeof of all the
constants, which means they are ints. That is why GCC doesn't say
anything about multi-character constants.
> > When I use signed char a, the warning
> > disappears
>
> Very strange...
If you adopt the view of '\xFD' as an int, it's not strange at all.
----------------------- a test program -----------------------------
#include <stdio.h.>
int main (void)
{
size_t s1 = sizeof ('c');
size_t s2 = sizeof (0xFD);
size_t s3 = sizeof ('\xFD');
printf ("size of 'c' is %ld; size of %u is %ld; size of %u is %ld\n",
s1, 0xFD, s2, '\xFD', s3);
return 0;
}
- Raw text -