From Mathias Froehlich, "Fix possible problem with aliasing rules... and fix a gcc warning :)
Use a union to determine if we are on a little endian or big endian machine." Merged from svn/trunk using : svn merge -r 10409:10410 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk/include/osg/
This commit is contained in:
@@ -26,9 +26,14 @@ enum Endian
|
||||
|
||||
inline Endian getCpuByteOrder()
|
||||
{
|
||||
static char big_endian_1[2] = { 0, 1 };
|
||||
union {
|
||||
char big_endian_1[2];
|
||||
short is_it_really_1;
|
||||
} u;
|
||||
u.big_endian_1[0] = 0;
|
||||
u.big_endian_1[1] = 1;
|
||||
|
||||
if ( (*((short*) big_endian_1)) == 1)
|
||||
if (u.is_it_really_1 == 1)
|
||||
return BigEndian;
|
||||
else
|
||||
return LittleEndian;
|
||||
|
||||
Reference in New Issue
Block a user