Mail Archives: djgpp/1997/10/28/09:00:26
Eli Zaretskii wrote:
>
> On Thu, 23 Oct 1997, Roman Suzi wrote:
>
> > --------------------------------------------------
> > unsigned char a;
> >
> > a = 253;
> >
> > if (a=='\xFD') {
> > ...
> > };
> > --------------------------------------------------
> >
> > Compiler gives warning, that
> > "comparison is always 0 due to limited range of data type"
> > (no matter with or without '-funsigned-char' flag)
>
> Change the offending line to say this:
>
> if (a == (unsigned char)'\xFD') {
>
> and it will compile without a warning.
You are right. Relying on the default setting of -fsigned-char or
-funsigned-char is dangerous. But '\xFD' should be positive when
compiled with -funsigned-char. I tested this and it also *is*. So either
Roman Suzi must use an older buggy compiler or he is using a defective
pgcc or I am missing something.
If you want avoid trouble always use explicit casts in these cases.
--
+----------------+
| Vik Heyndrickx |
+----------------+
- Raw text -