[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again

From: Lyndon Nerenberg
Subject: Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again
Date: Tue, 5 Feb 2013 09:54:03 -0800

On 2013-02-04, at 7:16 PM, David Levine wrote:

> How about this:  use unsigned char everywhere we can
> internally and compile with gcc -funsigned-char/Solaris cc
> -xchar=u?  Preserving that suggests using our own unsigned
> char type, though.

But to what benefit?  I.e. where is the gain in using "unsigned char" rather 
than just reverting to "char" everywhere.  This is what the C library uses for 
for its string and stdio functions.  The only time signed vs. unsigned makes a 
difference is if you are using chars as itty bitty ints.  Are we doing that?  
If so, why?  As for "wide characters,"  they are a separate entity from "char" 
and have no bearing on signed vs. unsigned char.

Switching to unsigned char means casting every parameter to almost every str* 
and stdio function call.  Besides being tedious, these casts will mask the 
cases where signed vs. unsigned actually matters.  This is just bad programming.

And if there does turn out to be a legitimate need for 8-bit integer 
arithmetic, that usage deserves its own new type, not only to point out the 
usage, but to ensure those objects aren't blindly confused with the normal 
usage of chars.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]