[En-Nut-Discussion] Yagarto from 23.12.2009 and newlib again...

Harald Kipp harald.kipp at egnite.de
Fri Feb 5 11:08:13 CET 2010


Hi Ulrich,

Ulrich Prinz wrote:
> Just a suggestion...
> 
> If we insert a definition like this
> 
> #ifndef USE_NEWLIB_CHARPTR
> #define NLIB_CHAR char
> #endif

What I found out is, that using compile options -funsigned-char or
-fsigned-char won't help. I wasn't aware, that char is a type of its own.

Furthermore, ISO C clearly states, that the argument of isXXX must be an
int or unsigned char. I understood, that

 char c;
 isalnum(c);

is not portable.

Although I refused to accept this first, we have to cast the isXXX
argument. I'd suggest using an unsigned char:

 char c;
 isalnum((unsigned char)c);

Furthermore, we should take care, that the char type is used for strings
only and that the code will not make any assumption about its
signedness. 8-bit values must explicitly use the signed or unsigned
specifier, or, even better, make use of stdint types int8_t and uint8_t.

Harald



More information about the En-Nut-Discussion mailing list