From 85fee2565364cb31b72252a07538c97a52e48ca7 Mon Sep 17 00:00:00 2001 From: Marcus Geelnard Date: Wed, 8 May 2019 14:59:06 +0200 Subject: MinGW fix: Use _MSC_VER instead of _WIN32 where appropriate Use _MSC_VER (instead of _WIN32) for things that are specific for Visual Studio. Also remove #include from hiredis.h, as it leaks too many symbols and defines into the global namespace, which is undesirable for a public interface header. Anyone who uses the the affected parts of the hiredis API needs to include the appropriate headers anyway in order to declare struct timeval variables. --- async.c | 6 ++---- hiredis.h | 4 ++-- sds.h | 2 +- sockcompat.h | 2 ++ win32.h | 10 ++++++++++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/async.c b/async.c index 171fabd..e46573f 100644 --- a/async.c +++ b/async.c @@ -32,11 +32,8 @@ #include "fmacros.h" #include #include -#ifndef _WIN32 +#ifndef _MSC_VER #include -#else -#define strcasecmp stricmp -#define strncasecmp strnicmp #endif #include #include @@ -46,6 +43,7 @@ #include "dict.c" #include "sds.h" #include "sslio.h" +#include "win32.h" #define _EL_ADD_READ(ctx) \ do { \ diff --git a/hiredis.h b/hiredis.h index 1ae1c0a..63eef3a 100644 --- a/hiredis.h +++ b/hiredis.h @@ -35,10 +35,10 @@ #define __HIREDIS_H #include "read.h" #include /* for va_list */ -#ifndef _WIN32 +#ifndef _MSC_VER #include /* for struct timeval */ #else -#include +struct timeval; /* forward declaration */ #endif #include /* uintXX_t, etc */ #include "sds.h" /* for sds */ diff --git a/sds.h b/sds.h index eafe2cf..bc92389 100644 --- a/sds.h +++ b/sds.h @@ -34,7 +34,7 @@ #define __SDS_H #define SDS_MAX_PREALLOC (1024*1024) -#ifdef _WIN32 +#ifdef _MSC_VER #define __attribute__(x) #endif diff --git a/sockcompat.h b/sockcompat.h index e0b2e5e..56006c1 100644 --- a/sockcompat.h +++ b/sockcompat.h @@ -50,7 +50,9 @@ #include #include +#ifdef _MSC_VER typedef signed long ssize_t; +#endif /* Emulate the parts of the BSD socket API that we need (override the winsock signatures). */ int win32_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); diff --git a/win32.h b/win32.h index 7cb5706..04289c6 100644 --- a/win32.h +++ b/win32.h @@ -2,10 +2,20 @@ #define _WIN32_HELPER_INCLUDE #ifdef _MSC_VER +#include /* for struct timeval */ + #ifndef inline #define inline __inline #endif +#ifndef strcasecmp +#define strcasecmp stricmp +#endif + +#ifndef strncasecmp +#define strncasecmp strnicmp +#endif + #ifndef va_copy #define va_copy(d,s) ((d) = (s)) #endif -- cgit v1.2.3