emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 024d20f: Fix compilation with mingw.org's MinGW 5


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 024d20f: Fix compilation with mingw.org's MinGW 5.x headers
Date: Sat, 28 Jul 2018 08:35:01 -0400 (EDT)

branch: emacs-26
commit 024d20f81e643fe1739d28d16501a8c4f7a860c6
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix compilation with mingw.org's MinGW 5.x headers
---
 lib-src/pop.c       | 8 ++++++--
 nt/inc/ms-w32.h     | 7 ++++++-
 nt/inc/sys/socket.h | 5 +++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib-src/pop.c b/lib-src/pop.c
index 10aac95..0b92045 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -30,8 +30,12 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "ntlib.h"
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501    /* for getaddrinfo stuff */
-#include <winsock2.h>
-#include <ws2tcpip.h>
+#if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000000L
+# include <windows.h>
+#else
+# include <winsock2.h>
+#endif
+# include <ws2tcpip.h>
 #undef getaddrinfo
 #define getaddrinfo  sys_getaddrinfo
 #undef freeaddrinfo
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index ff43178..0ab46e9 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -455,7 +455,12 @@ extern char *get_emacs_configuration_options (void);
    windows.h.  For this to have proper effect, config.h must always be
    included before windows.h.  */
 #define _WINSOCKAPI_    1
-#define _WINSOCK_H
+#if defined __MINGW32_VERSION && __MINGW32_VERSION < 5000000L
+/* mingw.org's MinGW 5.x changed how it includes winsock.h and time.h,
+   and now defining _WINSOCK_H skips the definition of struct timeval,
+   which we don't want.  */
+# define _WINSOCK_H
+#endif
 
 /* Defines size_t and alloca ().  */
 #include <stdlib.h>
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h
index 2582cbd..3ea9542 100644
--- a/nt/inc/sys/socket.h
+++ b/nt/inc/sys/socket.h
@@ -49,6 +49,11 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #define timeval ws_timeval
 #endif
 
+#if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000000L
+/* Need winerror.h before winsock2.h with mingw.org's MinGW 5.x,
+   otherwise some error codes are not defined.  */
+# include <winerror.h>
+#endif
 #include <winsock2.h>
 #include <ws2tcpip.h>
 /* process.c uses uint16_t (from C99) for IPv6, but



reply via email to

[Prev in Thread] Current Thread [Next in Thread]