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 --- OSC-client.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'OSC-client.h') diff --git a/OSC-client.h b/OSC-client.h index 1be5531..ca104c6 100644 --- a/OSC-client.h +++ b/OSC-client.h @@ -54,16 +54,21 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include "OSC-timetag.h" -/* The int4byte type has to be a 4-byte integer. You may have to - change this to long or something else on your system. */ -#ifdef __MWERKS__ - /* In Metrowerks you can set ints to be 2 or 4 bytes on 68K, but long is - always 4 bytes */ - typedef long int4byte; +#ifdef _MSC_VER +/* Microsoft Visual Studio is not C99, it does not provide stdint.h */ +typedef signed __int32 int32_t; +#elif defined(IRIX) +typedef long int32_t; /* a data type that has 32 bits */ #else - typedef int int4byte; +# include #endif +/* 32 bit "pointer cast" union */ +typedef union { + float f; + int32_t i; +} ls_pcast32; + /* The maximum depth of bundles within bundles within bundles within... This is the size of a static array. If you exceed this limit you'll get an error message. */ @@ -80,9 +85,9 @@ typedef struct OSCbuf_struct { int size; /* Size of the buffer */ char *bufptr; /* Current position as we fill the buffer */ int state; /* State of partially-constructed message */ - int4byte *thisMsgSize; /* Pointer to count field before + int32_t *thisMsgSize; /* Pointer to count field before currently-being-written message */ - int4byte *prevCounts[MAX_BUNDLE_NESTING]; + int32_t *prevCounts[MAX_BUNDLE_NESTING]; /* Pointers to count field before each currently open bundle */ int bundleDepth; /* How many sub-sub-bundles are we in now? */ @@ -165,7 +170,7 @@ int OSC_writeAddress(OSCbuf *buf, char *name); int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types); int OSC_writeFloatArg(OSCbuf *buf, float arg); int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args); -int OSC_writeIntArg(OSCbuf *buf, int4byte arg); +int OSC_writeIntArg(OSCbuf *buf, int32_t arg); int OSC_writeStringArg(OSCbuf *buf, char *arg); extern char *OSC_errorMessage; -- cgit v1.2.1