delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/27/17:00:30

Message-Id: <m0xPwlc-0003EjC@fwd13.btx.dtag.de>
Date: Mon, 27 Oct 1997 22:32:08 +0200
To: nuser AT rsuzi DOT pgu DOT karelia DOT ru, djgpp AT delorie DOT com
References: <ABVqtJqOH3 AT rsuzi DOT pgu DOT karelia DOT ru>
Subject: Re: [Q]: unsigned char
MIME-Version: 1.0
From: Georg DOT Kolling AT t-online DOT de (Georg Kolling)

Roman Suzi schrieb:
> Hi, all!
>
> I have encountered a problem with porting a program
> from BC++ 3.1 to gnu c++ (from DJGPP 2.01 package).
>
> The problem is best seen in this example of code:
> --------------------------------------------------
>   unsigned char a;
>
>   a = 253;
>
>   if (a=='\xFD') {
>    ...
>   };
> --------------------------------------------------
>
>   Compiler gives warning, that
> "comparison is always 0 due to limited range of data type"

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 assume you wanted to write " if (a==0xFD) {...} /* no ; here */ "
where 0xFD is hex representation of 253 decimal

>
>
> There were nothing of the sort in BC.
>
> When I use signed char a, the warning
> disappears

Very strange...

- Raw text -


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