signed vs unsigned pointer warning

Morten Welinder terra@gnome.org
Fri Oct 8 18:57:00 GMT 2004


   Why can't an implementation define isxxx(c) to return something like
       table_lookup[(unsigned)(c)]
   ?

Because isxxx needs to work with EOF, typically -1.

And regardless of the implementation's value of EOF, you cannot cast to
"unsigned char" either because that would make EOF collide with one of
the other 256 valid inputs.

So to summarize: someone screwed up with the definition of isxxx and it
is not fixable by the implementation.  Therefore, get used to seeing
code like

     const char *foo = whatever;
     if (isspace ((unsigned char)*foo)) oink ();

no matter how ugly it is.

Morten



More information about the Gcc mailing list