This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: signed vs unsigned pointer warning


   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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]