Mercurial > embed
comparison jansson/patch/snprintf.patch @ 5:9870264521f7
jansson: fix MSVC 2015 compilation
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 25 Feb 2016 09:01:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:2306f4b04790 | 5:9870264521f7 |
---|---|
1 diff --git a/cmake/jansson_private_config.h.cmake b/cmake/jansson_private_config.h.cmake | |
2 index ee1078f..ac7318f 100644 | |
3 --- a/cmake/jansson_private_config.h.cmake | |
4 +++ b/cmake/jansson_private_config.h.cmake | |
5 @@ -49,6 +49,20 @@ | |
6 | |
7 #cmakedefine HAVE_SNPRINTF 1 | |
8 | |
9 +/* snprintf should not be defined as macro with MSC_VER >= 1900 */ | |
10 +#if defined(_WIN32) || defined(WIN32) | |
11 +# if defined(_MSC_VER) /* MS compiller */ | |
12 +# if (_MSC_VER < 1900) /* snprintf not introduced */ | |
13 +# if !defined(snprintf) | |
14 +# define snprintf _snprintf | |
15 +# define HAVE_SNPRINTF 1 /* snprintf defined manually */ | |
16 +# endif | |
17 +# else | |
18 +# define HAVE_SNPRINTF 1 /* snprintf available via sdk */ | |
19 +# endif | |
20 +# endif | |
21 +#endif | |
22 + | |
23 #ifndef HAVE_SNPRINTF | |
24 # define snprintf @JSON_SNPRINTF@ | |
25 #endif | |
26 diff --git a/src/jansson_private.h b/src/jansson_private.h | |
27 index e100726..ccb3a57 100644 | |
28 --- a/src/jansson_private.h | |
29 +++ b/src/jansson_private.h | |
30 @@ -90,10 +90,20 @@ char *jsonp_strndup(const char *str, size_t length); | |
31 char *jsonp_strdup(const char *str); | |
32 char *jsonp_strndup(const char *str, size_t len); | |
33 | |
34 + | |
35 /* Windows compatibility */ | |
36 -#ifdef _WIN32 | |
37 -#define snprintf _snprintf | |
38 -#define vsnprintf _vsnprintf | |
39 +#if defined(_WIN32) || defined(WIN32) | |
40 +# if defined(_MSC_VER) /* MS compiller */ | |
41 +# if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */ | |
42 +# define snprintf _snprintf | |
43 +# endif | |
44 +# if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */ | |
45 +# define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) | |
46 +# endif | |
47 +# else /* Other Windows compiller, old definition */ | |
48 +# define snprintf _snprintf | |
49 +# define vsnprintf _vsnprintf | |
50 +# endif | |
51 #endif | |
52 | |
53 #endif |