delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/28/03:42:09

Date: Tue, 28 Oct 1997 10:42:02 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Georg Kolling <Georg DOT Kolling AT t-online DOT de>
cc: nuser AT rsuzi DOT pgu DOT karelia DOT ru, djgpp AT delorie DOT com
Subject: Re: [Q]: unsigned char
In-Reply-To: <m0xPwlc-0003EjC@fwd13.btx.dtag.de>
Message-ID: <Pine.SUN.3.91.971028104118.22947I-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019