fix strict-aliasing warning in byte swap tests

This commit is contained in:
Tyrann 2011-12-31 15:12:07 +10:00
parent 64f6e7da98
commit 1984cd1587
2 changed files with 14 additions and 4 deletions

View File

@ -1012,10 +1012,15 @@ COM_Init
void
COM_Init(char *basedir)
{
byte swaptest[2] = { 1, 0 };
union {
byte b[2];
short s;
} swaptest = {
.b = { 1, 0 }
};
// set the byte swapping variables in a portable manner
if (*(short *)swaptest == 1) {
if (swaptest.s == 1) {
bigendien = false;
BigShort = ShortSwap;
LittleShort = ShortNoSwap;

View File

@ -1094,10 +1094,15 @@ COM_Init
void
COM_Init(void)
{
byte swaptest[2] = { 1, 0 };
union {
byte b[2];
short s;
} swaptest = {
.b = { 1, 0 }
};
// set the byte swapping variables in a portable manner
if (*(short *)swaptest == 1) {
if (swaptest.s == 1) {
bigendien = false;
BigShort = ShortSwap;
LittleShort = ShortNoSwap;