aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Turvey <mturvey6@gmail.com>2018-03-10 23:07:43 -0700
committerMike Turvey <mturvey6@gmail.com>2018-03-10 23:10:19 -0700
commit5e59c6805ff7555930c9f10097cda6d90d57ee78 (patch)
treeb96aef00ab3f2053c87c1b6b11c49f09ac045852 /src
parentc3f6a9a94575035b4226fc646989d561efe5c3f4 (diff)
downloadlibsurvive-5e59c6805ff7555930c9f10097cda6d90d57ee78.tar.gz
libsurvive-5e59c6805ff7555930c9f10097cda6d90d57ee78.tar.bz2
Fix MSVC build
Diffstat (limited to 'src')
-rw-r--r--src/ootx_decoder.c7
-rwxr-xr-xsrc/survive.c2
-rwxr-xr-xsrc/survive_vive.c16
3 files changed, 23 insertions, 2 deletions
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)