some unusual errors

DJ Delorie
Mon Sep 21 15:22:00 GMT 1998

> This looks like a bug in the macro implementation of
> isspace(), to me; it should be casting the parameter to
> int so it will behave in the same way as the function
> implementation. Until a fix appears, your options are:

This discussion happens a lot in the djgpp newsgroup.  The
result is always the same: You can't cast to int in the
macro.  Why?  Because:

1. If the programmer used the macro with a char argument
(when char is signed), the macro can't tell the difference
between EOF and char 0xff

2. If char is signed, a cast to int may not do what the
macro is expecting.  The is*() macros normally expect a
parameter in the range 0..255 or -1, but if you cast a
signed char to int, you get values in the range -128..127 or
-1, and your program may crash.

3. Remember that getchar() returns in int - for the very
same reason, so that EOF is not in the range of valid
characters.  getchar() returns EOF or 0..255, which is NOT
the same range as the range for type `signed char'.

Basically, if you're a programmer and you've stumbled onto
this problem, you have a problem with your code.  60
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list