nmh-workers
[Top] [All Lists]

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

2013-02-05 11:54:25

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.

--lyndon


_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>