diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-12-13 05:21:56 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-12-13 05:21:56 +0000 |
commit | c0efacf6d17f17b37073965e1c91c782b86d2738 (patch) | |
tree | e267f7b800ba28aece57526b5f395c62e2dcfec2 /dumpOSC.c | |
parent | 510886a13161d27033c018632559a328145a9c83 (diff) |
fix float->int32_t and int32_t->float type-punningHEADsvn2git-headmaster
svn path=/branches/pd-extended/0.43/externals/oscx/; revision=16678
Diffstat (limited to 'dumpOSC.c')
-rw-r--r-- | dumpOSC.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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;
|