Martin Guy wrote:
Can you suggest a way to automatically detect endianness on your box
so that we can make a patch that will also work everywhere else?

At 02:03 AM 4/18/2007, James McGill wrote:
const unsigned int IS_LITTLE_ENDIAN_TEST_BIT = 1u;

// If left-most byte of 1 is non-zero, we're little endian
const bool IS_LITTLE_ENDIAN =
*reinterpret_cast<const unsigned char*>(&IS_LITTLE_ENDIAN_TEST_BIT) == 1;

For the record:

This works assuming that sizeof( unsigned char ) < sizeof( unsigned int ), which isn't true of all implementations any more, given Unicode. Since the test works for any two discrete, integral types, I'd suggest using 'long', for safety, or even 'long long', and also including the test
        sizeof( A ) < sizeof( B )
to ensure the types really are of different lengths.

Eric



_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev

Reply via email to