summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjinjiazhang <jinjiazhang@tencent.com>2019-04-13 10:38:34 +0800
committerjinjiazhang <jinjiazhang@tencent.com>2019-04-13 10:38:34 +0800
commitcdb836d5f845d2bf0fbe58671d073869f41a9936 (patch)
tree1c54c2f3327c67da17bf718eb9dc353cc168bfda
parent5aa2397f9ec494380774fb9155446f14ebbf3d1f (diff)
Fix Compile Error On Windows (Visual Studio)
-rw-r--r--async.c5
-rw-r--r--hiredis.h4
-rw-r--r--sds.h3
-rw-r--r--sockcompat.h2
4 files changed, 14 insertions, 0 deletions
diff --git a/async.c b/async.c
index b6163f2..50eb2d9 100644
--- a/async.c
+++ b/async.c
@@ -32,7 +32,12 @@
#include "fmacros.h"
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
#include <strings.h>
+#else
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
diff --git a/hiredis.h b/hiredis.h
index 6e56c5e..1ae1c0a 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -35,7 +35,11 @@
#define __HIREDIS_H
#include "read.h"
#include <stdarg.h> /* for va_list */
+#ifndef _WIN32
#include <sys/time.h> /* for struct timeval */
+#else
+#include <winsock2.h>
+#endif
#include <stdint.h> /* uintXX_t, etc */
#include "sds.h" /* for sds */
diff --git a/sds.h b/sds.h
index 13be75a..eafe2cf 100644
--- a/sds.h
+++ b/sds.h
@@ -34,6 +34,9 @@
#define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024)
+#ifdef _WIN32
+#define __attribute__(x)
+#endif
#include <sys/types.h>
#include <stdarg.h>
diff --git a/sockcompat.h b/sockcompat.h
index 4965b7b..e0b2e5e 100644
--- a/sockcompat.h
+++ b/sockcompat.h
@@ -50,6 +50,8 @@
#include <ws2tcpip.h>
#include <stddef.h>
+typedef signed long ssize_t;
+
/* 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);
const char *win32_gai_strerror(int errcode);