delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/24/07:33:41

Message-ID: <004401bf664a$8324bfe0$0307028a@prmivv03>
From: "Petr Maxa" <maxa AT sse-za DOT sk>
To: <djgpp AT delorie DOT com>
References: <000701bf63ef$41a61440$0307028a AT prmivv03> <869r7t$j4d$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
Subject: Re: signed - unsigned chars
Date: Mon, 24 Jan 2000 10:07:59 +0100
Organization: SSE s.p. Zilina
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Reply-To: djgpp AT delorie DOT com

Thanks to everyone who responded to original message.

On Fri, 21 Jan 2000, Andris Pavenis and Shawn Hargreaves wrote:

: use  -funsigned-char

The compiler switch  "-funsigned-char" does not really helped as character
constants like 'A' or arrays like "Hi" are implicitly signed. I must have
overtyped most of these instances in this case.

On Fri, 21 Jan 2000, Damian Yerrick  wrote:

:typedef unsigned char byte;
:and use byte instead of char.
:const byte tilde = '~';

Surprisingly this code works, but works only for single constants not for
arrays, so
const byte *hi = "Hi";
won't work without overtyping.

On Fri, 21 Jan 2000, Hans-Bernhard Broeker wrote:

: Bad coding in that project, then. If they had to have unsigned chars,
: they should have *coded* unsigned chars, not rely on some compiler
: switch to automagically do it for them...

True and I must admit, that I have just rewritten the code to distinguish
between signed or unsigned char although we need only the unsigned type of
the char.

The problem is solved, but is not as neat as I would expect, because I still
have to mix signed and unsigned types when I use libc functions like printf,
sprintf in the case, that the unsigned type is readable text and need to be
printed or when the buffers may use both text and binary (unsigned)
information.




- Raw text -


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