From 0e147b9e52ead07cb3a2857d2f9ff980d7aca3a9 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 12 Jan 2019 23:00:55 +0000 Subject: [PATCH 1/3] Fix: A few minor compile warnings under MinGW --- src/os/windows/win32.cpp | 1 + src/video/win32_v.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index bb1a0a42099b..a84347ed144c 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -17,6 +17,7 @@ #include #include #include +#define NO_SHOBJIDL_SORTDIRECTION // Avoid multiple definition of SORT_ASCENDING #include /* SHGetFolderPath */ #include #include "win32.h" diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 0655065a6c03..29a065720358 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -238,7 +238,7 @@ int RedrawScreenDebug() #define TID_POLLMOUSE 1 #define MOUSE_POLL_DELAY 75 -static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT event, DWORD time) +static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT_PTR event, DWORD time) { RECT rc; POINT pt; From 9d3f6c5d180f3052dda07c68485e7936c42cdab7 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sun, 13 Jan 2019 16:12:52 +0000 Subject: [PATCH 2/3] Codechange: Remove unnecessarily defined functions under MinGW --- src/network/core/os_abstraction.h | 88 +------------------------------ src/os/windows/win32.cpp | 3 -- src/video/win32_v.cpp | 4 +- 3 files changed, 3 insertions(+), 92 deletions(-) diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h index c320cd9102bb..32c6cffff27d 100644 --- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -38,93 +38,7 @@ typedef unsigned long in_addr_t; typedef SSIZE_T ssize_t; typedef int socklen_t; # define IPPROTO_IPV6 41 -#else -#include "../../os/windows/win32.h" -#include "../../core/alloc_func.hpp" - -#define AI_ADDRCONFIG 0x00000400 /* Resolution only if global address configured */ -#define IPV6_V6ONLY 27 - -static inline int OTTDgetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, DWORD hostlen, char *serv, DWORD servlen, int flags) -{ - static int (WINAPI *getnameinfo)(const struct sockaddr *, socklen_t, char *, DWORD, char *, DWORD, int) = NULL; - static bool first_time = true; - - if (first_time) { - LoadLibraryList((Function*)&getnameinfo, "ws2_32.dll\0getnameinfo\0\0"); - first_time = false; - } - - if (getnameinfo != NULL) return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); - - strncpy(host, inet_ntoa(((const struct sockaddr_in *)sa)->sin_addr), hostlen); - return 0; -} -#define getnameinfo OTTDgetnameinfo - -static inline int OTTDgetaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) -{ - static int (WINAPI *getaddrinfo)(const char *, const char *, const struct addrinfo *, struct addrinfo **) = NULL; - static bool first_time = true; - - if (first_time) { - LoadLibraryList((Function*)&getaddrinfo, "ws2_32.dll\0getaddrinfo\0\0"); - first_time = false; - } - - if (getaddrinfo != NULL) return getaddrinfo(nodename, servname, hints, res); - - *res = NULL; - - in_addr_t ip = inet_addr(nodename); - if (ip == INADDR_NONE) { - struct hostent *he = gethostbyname(nodename); - if (he == NULL) return EAI_NONAME; - ip = (*(struct in_addr *)he->h_addr).s_addr; - } - - struct sockaddr_in *sin = CallocT(1); - sin->sin_family = AF_INET; - sin->sin_port = htons(strtoul(servname, NULL, 10)); - sin->sin_addr.s_addr = ip; - - struct addrinfo *ai = CallocT(1); - ai->ai_family = PF_INET; - ai->ai_addr = (struct sockaddr*)sin; - ai->ai_addrlen = sizeof(*sin); - ai->ai_socktype = hints->ai_socktype; - - *res = ai; - return 0; -} -#define getaddrinfo OTTDgetaddrinfo - -static inline void OTTDfreeaddrinfo(struct addrinfo *ai) -{ - static int (WINAPI *freeaddrinfo)(struct addrinfo *) = NULL; - static bool first_time = true; - - if (ai == NULL) return; - - if (first_time) { - LoadLibraryList((Function*)&freeaddrinfo, "ws2_32.dll\0freeaddrinfo\0\0"); - first_time = false; - } - - if (freeaddrinfo != NULL) { - freeaddrinfo(ai); - return; - } - - do { - struct addrinfo *next = ai->ai_next; - free(ai->ai_addr); - free(ai); - ai = next; - } while (ai != NULL); -} -#define freeaddrinfo OTTDfreeaddrinfo -#endif /* __MINGW32__ && __CYGWIN__ */ +#endif /* !(__MINGW32__ && __CYGWIN__) */ #endif /* _WIN32 */ /* UNIX stuff */ diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index a84347ed144c..4a49555492e3 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -31,10 +31,7 @@ #include #include "../../language.h" -/* Due to TCHAR, strncat and strncpy have to remain (for a while). */ #include "../../safeguards.h" -#undef strncat -#undef strncpy static bool _has_console; static bool _cursor_disable = true; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 29a065720358..6cee4fef2819 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -636,7 +636,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP switch (msg) { case WM_CREATE: - SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); + SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, TrackMouseTimerProc); SetCompositionPos(hwnd); _imm_props = ImmGetProperty(GetKeyboardLayout(0), IGP_PROPERTY); break; @@ -741,7 +741,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP _pTrackMouseEvent(&tme); } else { - SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); + SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, TrackMouseTimerProc); } } From f4a4c9bfe7b5c2bc0e6ad4bcb5a8c0297641c269 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Wed, 16 Jan 2019 19:28:52 +0000 Subject: [PATCH 3/3] Codechange: Don't explicitly link with -lstdc++, causes linking issues with freetype on MinGW --- config.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lib b/config.lib index 1af354e163fa..843d6c3c8347 100644 --- a/config.lib +++ b/config.lib @@ -1508,7 +1508,7 @@ make_cflags_and_ldflags() { CXXFLAGS_ENV="$CXXFLAGS" CXXFLAGS="" # Libs to compile. In fact this is just LDFLAGS - LIBS="-lstdc++" + LIBS="" # LDFLAGS used for HOST LDFLAGS_ENV="$LDFLAGS" LDFLAGS=""