Re: [cc65] why this doesn't work?

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-06-07 08:25:31
On Sun, Jun 06, 2010 at 07:59:29PM -0700, Steve Davison wrote:
> Hold on here... While I agree that type char SHOULD be defined as
> unsigned, it traditionally always has been an 8-bit signed value.

The C standard doesn't define the signedness of type "char", this decision is
up to the implemention. Because of obvious reasons, cc65 implements them as
unsigned chars. Any code that makes an assumption about the signedness of
plain char is non portable.

If you want signed chars, use "signed char", if you want unsigned char, use
"unsigned char". If signedness doesn't matter, use "char".

> Every C compiler I have ever used, including CC65, has considered it
> signed (at least by default).

For cc65, this is wrong. For every other compiler you've used: Maybe, but that
doesn't prove anything. Many people haven't used a platform where a char has
something else than 8 bits, but despite of that, a char size of, say, 32 bits
is fully legal for a conforming C implementation. And any source that assumes
that a char has 8 bits is non portable (as far as the standard goes).

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jun 7 08:25:38 2010

This archive was generated by hypermail 2.1.8 : 2010-06-07 08:25:41 CEST