Changeset 10410

Show
Ignore:
Timestamp:
06/25/09 15:26:26 (5 years ago)
Author:
robert
Message:

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."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/Endian

    r5471 r10410  
    2727inline Endian getCpuByteOrder() 
    2828{ 
    29     static char big_endian_1[2] = { 0, 1 }; 
     29    union { 
     30        char big_endian_1[2]; 
     31        short is_it_really_1; 
     32    } u; 
     33    u.big_endian_1[0] = 0; 
     34    u.big_endian_1[1] = 1; 
    3035 
    31     if ( (*((short*) big_endian_1)) == 1) 
     36    if (u.is_it_really_1 == 1) 
    3237        return BigEndian; 
    3338    else