From: Vik Heyndrickx Newsgroups: comp.os.msdos.djgpp Subject: Re: [Q]: unsigned char Date: Mon, 27 Oct 1997 09:14:08 +0100 Organization: University of Ghent, Belgium Lines: 36 Message-ID: <34544D50.639D@rug.ac.be> References: NNTP-Posting-Host: eduserv1.rug.ac.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 | +----------------+