From fd35fd98035735bc91c55d14832461e41dd0e193 Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 31 Jan 2017 13:09:55 +0800 Subject: feature: supports MS C compiler older than VC2012. Signed-off-by: Yichun Zhang (agentzh) --- fpconv.c | 6 ++++++ lua-cjson-2.1devel-1.rockspec | 2 +- lua_cjson.c | 10 ++++++++++ strbuf.h | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/fpconv.c b/fpconv.c index 854662c..3e480ec 100644 --- a/fpconv.c +++ b/fpconv.c @@ -35,6 +35,12 @@ #include "fpconv.h" +/* Workaround for MSVC */ +#ifdef _MSC_VER +#define inline __inline +#define snprintf sprintf_s +#endif + /* Lua CJSON assumes the locale is the same for all threads within a * process and doesn't change after initialisation. * diff --git a/lua-cjson-2.1devel-1.rockspec b/lua-cjson-2.1devel-1.rockspec index 154e333..d614d05 100644 --- a/lua-cjson-2.1devel-1.rockspec +++ b/lua-cjson-2.1devel-1.rockspec @@ -47,7 +47,7 @@ build = { -- Override default build options (per platform) platforms = { win32 = { modules = { cjson = { defines = { - "DISABLE_INVALID_NUMBERS" + "DISABLE_INVALID_NUMBERS", "USE_INTERNAL_ISINF" } } } } }, copy_directories = { "tests" } diff --git a/lua_cjson.c b/lua_cjson.c index 1695979..89cba6d 100644 --- a/lua_cjson.c +++ b/lua_cjson.c @@ -54,6 +54,16 @@ #define CJSON_VERSION "2.1devel" #endif +#ifdef _MSC_VER +#define snprintf sprintf_s + +#ifndef isnan +#include +#define isnan(x) _isnan(x) +#endif + +#endif + /* Workaround for Solaris platforms missing isinf() */ #if !defined(isinf) && (defined(USE_INTERNAL_ISINF) || defined(MISSING_ISINF)) #define isinf(x) (!isnan(x) && isnan((x) - (x))) diff --git a/strbuf.h b/strbuf.h index d861108..5df0b7b 100644 --- a/strbuf.h +++ b/strbuf.h @@ -25,6 +25,11 @@ #include #include +/* Workaround for MSVC */ +#ifdef _MSC_VER +#define inline __inline +#endif + /* Size: Total bytes allocated to *buf * Length: String length, excluding optional NULL terminator. * Increment: Allocation increments when resizing the string buffer. -- cgit v1.2.3-55-g6feb