Date: Sun, 26 Oct 1997 17:12:49 +0200 (IST) From: Eli Zaretskii To: Roman Suzi cc: djgpp AT delorie DOT com Subject: Re: [Q]: unsigned char In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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 mixing signed and unsigned integers ('\xFD' is treated as a signed integer by default), which can get you into VERY subtle bugs. Avoid this at all costs by always either using unsigned constants, like in 253U, or, where the syntax doesn't allow it (e.g., you cannot say '\xFD'U), by casting it explicitly to an unsigned type before every operation. > Are there any documents about porting > programs from BC/TC to DJGPP/gnu C++ > beyond djgppfaq? This is not a porting problem, it's an ANSI C problem. Check out the C language FAQ posted to comp.lang.c group.