unsigned char in getc()?
David Warren
warren@cs.sunysb.edu
Tue Jan 20 23:16:00 GMT 2004
I'm getting an int value of -80 returned by getc(), whereas fgetc()
returns 176 for the same input character. This seems to be caused by
the definition of getc() in cygwin/usr/include/mingw/stdio.h, which
is:
__CRT_INLINE int __cdecl getc (FILE* __F)
{
return (--__F->_cnt >= 0)
? (int) *__F->_ptr++
: _filbuf (__F);
}
The _ptr field is of type char* (not unsigned char*).
A definition of getc() I found elsewhere is:
#define getc(_stream) (--(_stream)->_cnt >= 0 \
? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
which and's in the 0xff to get the unsigned value.
This seems to have become broken in a recent gcc. Shouldn't this be
fixed, or am I misunderstanding something?
-David S. Warren
XSB, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list