From 995cfd4bbd5cc95adfc4be582b3e04f65c05d782 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 23 Sep 2016 23:04:28 +0200 Subject: [PATCH 1/4] Update the msvc project file. --- msvc/libdivecomputer.vcproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/msvc/libdivecomputer.vcproj b/msvc/libdivecomputer.vcproj index 52781f2..2f3dcdf 100644 --- a/msvc/libdivecomputer.vcproj +++ b/msvc/libdivecomputer.vcproj @@ -462,6 +462,10 @@ RelativePath="..\src\suunto_vyper_parser.c" > + + @@ -752,6 +756,10 @@ RelativePath="..\include\libdivecomputer\units.h" > + + From 53c75860a73068a4f51305aeb36762e409a1a63b Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 26 Sep 2016 19:54:42 +0200 Subject: [PATCH 2/4] Add some workarounds for the msvc compiler. --- src/suunto_eonsteel_parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 64a01ca..5bc2590 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -30,6 +30,16 @@ #include "parser-private.h" #include "array.h" +#ifdef _MSC_VER +#define strcasecmp _stricmp +#if _MSC_VER < 1800 +// The rint() function is only available in MSVC 2013 and later +// versions. Our replacement macro isn't entirely correct, because the +// rounding rules for halfway cases are slightly different (away from +// zero vs to even). But for our use-case, that's not a problem. +#define rint(x) ((x) >= 0.0 ? floor((x) + 0.5): ceil((x) - 0.5)) +#endif +#endif #define C_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) From e7ceb96627188aaa16915786e82deb7f15284630 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 26 Sep 2016 19:59:18 +0200 Subject: [PATCH 3/4] Add explicit casts for the msvc C++ compiler. --- src/suunto_eonsteel_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 5bc2590..a2fa3ee 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -678,7 +678,7 @@ static const char *lookup_enum(const struct type_desc *desc, unsigned char value if (n != value) continue; - ret = malloc(end - begin + 1); + ret = (char *)malloc(end - begin + 1); if (!ret) break; @@ -1177,7 +1177,7 @@ static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *d else if (!strcasecmp(name, "Oxygen")) ; else if (!strcasecmp(name, "None")) - tankinfo = 0; + tankinfo = DC_TANKVOLUME_NONE; else if (strcasecmp(name, "Primary")) DEBUG(eon->base.context, "Unknown gas type %u (%s)", type, name); @@ -1344,7 +1344,7 @@ static int traverse_diving_fields(suunto_eonsteel_parser_t *eon, const struct ty } if (!strcmp(name, "DiveMode")) { - if (!strncmp(data, "CCR", 3)) { + if (!strncmp((const char *)data, "CCR", 3)) { eon->cache.divemode = DC_DIVEMODE_CC; eon->cache.initialized |= 1 << DC_FIELD_DIVEMODE; } From 81c19446047c5b80e23487487e8c6793bae79944 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 26 Sep 2016 20:37:25 +0200 Subject: [PATCH 4/4] Include the public header in the implementation file. In the public header files, all symbols are marked extern C. When using a C compiler, there is usually no problem if the header isn't included in the C file. But the msvc build system uses the C++ compiler (due to the use of some C99 features not supported by the msvc C compiler). --- src/hw_ostc_parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 48eae3d..2a43dee 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -22,6 +22,7 @@ #include #include +#include #include "libdivecomputer/units.h" #include "context-private.h"