From c0efacf6d17f17b37073965e1c91c782b86d2738 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 13 Dec 2012 05:21:56 +0000 Subject: fix float->int32_t and int32_t->float type-punning svn path=/branches/pd-extended/0.43/externals/oscx/; revision=16678 --- dumpOSC.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'dumpOSC.c') diff --git a/dumpOSC.c b/dumpOSC.c index 6fc4da6..cf90da5 100644 --- a/dumpOSC.c +++ b/dumpOSC.c @@ -156,6 +156,12 @@ static int unixinitudp(int chan); #endif +/* 32 bit "pointer cast" union */ +typedef union { + float f; + long i; +} ls_pcast32; + static int initudp(int chan); static void closeudp(int sockfd); @@ -810,12 +816,12 @@ static void dumpOSC_PrintTypeTaggedArgs(t_dumpOSC *x, void *v, int n) { break; case 'f': { - int i = ntohl(*((int *) p)); - t_float *floatp = ((t_float *) (&i)); + long i = ntohl(*((long *) p)); + ls_pcast32 *pc = (ls_pcast32 *)(&i); #ifdef DEBUG - post("float: %f", *floatp); + post("float: %f", (*pc).f); #endif - SETFLOAT(mya+myargc,*floatp); + SETFLOAT(mya+myargc, (*pc).f); myargc++; p += 4; -- cgit v1.2.1