|
On May 04, 2006, at 21:41, Joshua Jensen wrote:
Luiz Henrique de Figueiredo wrote:A small point of interest. When working the Xbox 360, the above endianness didn't work using a local variable. Instead, I had to create a static global. :( This was under Lua 5.0, but I'm guessing it will still apply now.void luaU_header (char* h) { int x=1; *h++=(char)*(char*)&x; /* endianness */ }static int x = 1; int luaU_endianness (void) { /* int x=1; */ return *(char*)&x; } Take it for what it's worth.
A compiler bug. Accessing any C type by treating it as an array of char is completely legal. Aliasing must be be honoured. That's how memcpy works, it copies objects char by char (at least conceptually).
drj