gcc-4.6: correct strict aliasing errors.

Use "union" to remove error:

"error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]"

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Laurent Vivier 2011-12-16 05:14:24 +01:00
parent f2be9d761f
commit 8cde86073a
3 changed files with 7 additions and 3 deletions

View File

@ -21,7 +21,7 @@ OSErr SerGetBuf(short refNum, long *count)
res = PBStatusSync((ParmBlkPtr)&param);
*count = *(long*)param.csParam;
*count = param.csParamLong;
return res;
}

View File

@ -48,7 +48,11 @@ struct CntrlParam {
COMMON_PARAMS
int16_t ioCRefNum;
int16_t csCode;
int16_t csParam[11];
union {
int16_t csParam[11];
long csParamLong;
void * csParamPtr;
};
};
typedef struct CntrlParam CntrlParam;
typedef CntrlParam* CntrlParamPtr;

View File

@ -83,7 +83,7 @@ static inline OSErr GetCurrentMode(short refNum, VDSwitchInfoRec *hwMode)
param.csCode = cscGetCurMode;
param.ioCRefNum = refNum;
*((VDSwitchInfoRec **)&param.csParam[0]) = hwMode;
param.csParamPtr = hwMode;
return PBStatusSync((ParmBlkPtr)&param);
}