Mail Archives: djgpp/1997/07/16/11:18:21
> But compiler warned that I am comparing unsigned and signed.
So tell the compiler to shut up. With GCC 2.7.2.2 and earlier, you
must explicitly ask it to report signed/unsigned comparison problems
with -Wsign-compare. That is -Wall does not include it.
The latest developers version (last year or
so) of gcc, along with pgcc as well, include -Wsign-compare along
with -Wall. So, either remove -Wsign-compare if you are using
it, or add -Wno-sign-compare after -Wall if you have a developers
version.
> And it
> was right: size_t is unsigned long! Anyone knows how fread or fwrite
> can return -1 on error while its return value is unsigned?
Remember, intel uses 2's complement, which are represented in
32 bit values just like unsigned are.
Take -1
1) Remove the sign, you get
0x00000001
2) Complement the number
0xFFFFFFFE
3) Add one to it
0xFFFFFFFF
Most people think its easier to write negative one, and have it converted
into its unsigned representation, that to write out that huge value.
Andrew
- Raw text -