egcs, casting the argument of eg isalpha to an int...
Lassi A. Tuura
Lassi.Tuura@cern.ch
Mon Feb 16 03:54:00 GMT 1998
Kaveh R. Ghazi wrote:
|> I'm thinking of changing them to this:
|>
|> > #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (((int)(c))))
|>
|> This would seem to avoid the warning.
|>
|> Is this solution correct from a technical standpoint?
Often characters must be casted to `unsigned char' before being used
with is* functions. The reason is that the functions require the
argument to be an int with non-negative or EOF value. If you pass in a
char and chars are signed, a character with the high bit set receives
incorrect treatment (sign extension). Thus, if you got the character by
scanning a string, convert it to `unsigned char' first to make sure this
does not happen. If you got it from fgetc, no conversion is necessary
-- but you must make sure you use int in the first place, and not
convert the returned value to char.
//lat
--
Lassi.Tuura@cern.ch There's no sunrise without a night
More information about the Gcc
mailing list