Page 1 of 1

sdcc has made chars unsigned by default rather than signed

Posted: Sat Apr 02, 2016 6:01 am
by alvin
Recently sdcc has changed its char type to be unsigned by default. For programs that expect signed chars this can lead to errors and warnings. Compiling with an additional command line flag "--fsigned-char" will cause sdcc to treat char as a signed type as was the default before the change. This affects the current zsdcc binary supplied by z88dk.

The reason for the change is that small uPs, including the z80, are better suited to unsigned types and use of unsigned char rather than signed char leads to faster and more compact code. The thinking is people who use "char" to declare variables are not consciously making a decision about whether "char" should be signed or unsigned. The C standard specifically states that whether char is signed or not is implementation defined. Portable C code should always use "signed char" or "unsigned char" to declare char-size variables.