From 86377e19d315e04f5469a6090e7ea2f1ae5e8c4d Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Sat, 20 Oct 2007 04:45:43 +0000 Subject: Modified OSC_writeFloatArg for strict aliasing svn path=/trunk/externals/mrpeach/; revision=8850 --- osc/packOSC.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'osc') diff --git a/osc/packOSC.c b/osc/packOSC.c index 0849769..3b66782 100755 --- a/osc/packOSC.c +++ b/osc/packOSC.c @@ -1119,15 +1119,21 @@ static int CheckTypeTag(OSCbuf *buf, char expectedType) static int OSC_writeFloatArg(OSCbuf *buf, float arg) { - int4byte *intp; + union intfloat32 + { + int i; + float f; + }; + union intfloat32 if32; if(OSC_CheckOverflow(buf, 4))return 1; if (CheckTypeTag(buf, 'f')) return 9; /* Pretend arg is a long int so we can use htonl() */ - intp = ((int4byte *) &arg); - *((int4byte *) buf->bufptr) = htonl(*intp); + if32.f = arg; + + *((int4byte *) buf->bufptr) = htonl(if32.i); buf->bufptr += 4; -- cgit v1.2.1