|
 |
Warp wrote:
>
> This can't work this way. If it did, then if you make this:
It works. It wasn't pretty.
On x86, if you lay out 0x01020304 in memory, it becomes
04 03 02 01 which is what you are used to.
if you read this as a (32 bit) int then you get back your 0x01020304.
Reading it as a char you get 0x04.
So using TRUE=1 flows naturally with this scheme.
01 00 00 00 is 1 whether read as 8 or 32 bits.
But on a big endian machine, i=0x01020304 is laid out
01 02 03 04. So if you read (char)i you get 01.
So if (int)i = TRUE=1 or 00 00 00 01, then reading (char)i gives you 0.
So (int)i = TRUE = -1 or FF FF FF FF, gives you non-zero in any size.
Like i said, these were the old days. Now i believe on Sparcs and 680x0
there is an implied offset, such that (char)i is read as *((char)i)+3).
Hmm, that seems even weirder; what would ((char)i)+1) give you.
Beats me. So i took a jaunt through my old K&R and there is no mention
anywhere of TRUE, FALSE, BOOL or boolean. It does mention that UNIX
is 16000 lines of C :) and that the assignment
int i 1; /* is legal but deprecated */
Also, the equivilant of += and -= , which is =+ and =- is now frowned upon
for obvious reasons. x =-1;
Old book.
dik
Post a reply to this message
|
 |