This is the mail archive of the
cygwin
mailing list for the Cygwin project.
unsigned char in getc()?
- From: David Warren <warren at cs dot sunysb dot edu>
- To: cygwin at cygwin dot com
- Date: Tue, 20 Jan 2004 17:43:15 -0500 (EST)
- Subject: unsigned char in getc()?
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/