From 5e59c6805ff7555930c9f10097cda6d90d57ee78 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Sat, 10 Mar 2018 23:07:43 -0700 Subject: Fix MSVC build --- src/ootx_decoder.c | 7 ++++++- src/survive.c | 2 +- src/survive_vive.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ootx_decoder.c b/src/ootx_decoder.c index b7327d5..0620284 100644 --- a/src/ootx_decoder.c +++ b/src/ootx_decoder.c @@ -182,10 +182,15 @@ union iFloat { float f; }; - +#ifndef _MSC_VER struct __attribute__((__packed__)) unaligned_u16_t { uint16_t v; }; +#else +struct unaligned_u16_t { + uint16_t v; +}; +#endif float _half_to_float(uint8_t* data) { uint16_t x = ((struct unaligned_u16_t*)data)->v; diff --git a/src/survive.c b/src/survive.c index 21e1f0e..5d0d35f 100755 --- a/src/survive.c +++ b/src/survive.c @@ -96,7 +96,7 @@ static void *button_servicer(void * context) void survive_verify_FLT_size(uint32_t user_size) { if(sizeof(FLT) != user_size) { - fprintf(stderr, "FLT type incompatible; the shared library libsurvive has FLT size %lu vs user program %u\n", sizeof(FLT), user_size); + fprintf(stderr, "FLT type incompatible; the shared library libsurvive has FLT size %lu vs user program %u\n", (unsigned long)sizeof(FLT), user_size); fprintf(stderr, "Add '#define FLT %s' before including survive.h or recompile the shared library with the appropriate flag. \n", sizeof(FLT) == sizeof(double) ? "double" : "float"); exit(-1); diff --git a/src/survive_vive.c b/src/survive_vive.c index 5001efd..f250c22 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -904,6 +904,7 @@ int survive_get_config( char ** config, SurviveViveData * sv, int devno, int ifa #define POP1 (*(readdata++)) +#ifndef _MSC_VER struct __attribute__((__packed__)) unaligned_16_t { int16_t v; }; @@ -916,6 +917,21 @@ struct __attribute__((__packed__)) unaligned_u16_t { struct __attribute__((__packed__)) unaligned_u32_t { uint32_t v; }; +#else +struct unaligned_16_t { + int16_t v; +}; +struct unaligned_32_t { + int32_t v; +}; +struct unaligned_u16_t { + uint16_t v; +}; +struct unaligned_u32_t { + uint32_t v; +}; +#endif + #define POP2 ((((( struct unaligned_u16_t*)((readdata+=2)-2))))->v) #define POP4 ((((( struct unaligned_u32_t*)((readdata+=4)-4))))->v) -- cgit v1.2.3