summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2005-12-16 20:55:07 +0000
committerYang Tse <yangsita@gmail.com>2005-12-16 20:55:07 +0000
commit9950522a46cb6bf8dc962ca7641fe92d44527cc5 (patch)
treecd6ebbf6de0b4e1f0d1c1d6515a7fca0920f4d98
parente4c8fa8111aea9067309d041c7d92ded3aad2af0 (diff)
downloadc-ares-9950522a46cb6bf8dc962ca7641fe92d44527cc5.tar.gz
c-ares-9950522a46cb6bf8dc962ca7641fe92d44527cc5.tar.bz2
c-ares-9950522a46cb6bf8dc962ca7641fe92d44527cc5.zip
'Fix' windows builds
-rw-r--r--config-win32.h4
-rw-r--r--setup.h30
2 files changed, 32 insertions, 2 deletions
diff --git a/config-win32.h b/config-win32.h
index 5026728..4847507 100644
--- a/config-win32.h
+++ b/config-win32.h
@@ -16,6 +16,10 @@
#ifndef __CONFIG_WIN32_H
#define __CONFIG_WIN32_H
+#define HAVE_WINDOWS_H
+#define HAVE_WINSOCK2_H
+#define HAVE_WS2TCPIP_H
+
#if defined(__MINGW32__)
#define HAVE_GETOPT_H
#endif
diff --git a/setup.h b/setup.h
index 831bda4..05eb76b 100644
--- a/setup.h
+++ b/setup.h
@@ -22,6 +22,34 @@
#include "config-win32.h"
#endif
+
+/*
+ * Include header files for windows builds before redefining anything.
+ * Use this preproessor block only to include or exclude windows.h,
+ * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
+ * to any other further and independant block.
+ */
+
+#ifdef WIN32
+# ifdef HAVE_WINDOWS_H
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# ifdef HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+# endif
+# else
+# ifdef HAVE_WINSOCK_H
+# include <winsock.h>
+# endif
+# endif
+# endif
+#endif
+
+
/* simple work-around for now, for systems without configure support */
#ifndef __DJGPP__
#define ssize_t int
@@ -44,8 +72,6 @@
/* now typedef our socket type */
#if defined(WIN32) && !defined(WATT32)
-#include <winsock2.h>
-#include <ws2tcpip.h>
typedef SOCKET ares_socket_t;
#define ARES_SOCKET_BAD INVALID_SOCKET
#else