On 27 Jan 2009, at 14:23, Adam Venturella wrote:
Leopard is little endian ( at least on the intel chips, but I have read there are other macs that are big-endian, so I am trying to catch and handle that accordingly)
The endianness is dependent on the processor architecture, not the operating system. Intel Macs are little endian, but PowerPC Macs are big endian no matter which OS is running on them.
With regard to how the casting is actually working, I just want to make sure I understand the logic: uint key = *(uint*)&buffer; from right to left this is what is happening: Get a pointer/reference to 'buffer'. Cast that pointer into a uint pointer. Then, dereference the pointer to get it's value. Is that correct?
Yes. That is correct, but since buffer is already a pointer to the first byte of the array and then you are taking a reference to it, key will end up containing the address of the buffer. You really need:
uint key = *(uint*)buffer;
_______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
