From 15445a0fbe06c85836f9e8844ffc18ff672b7f08 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 3 May 2023 12:54:42 +0200 Subject: [PATCH] Raise and clean up _WIN32_WINNT constant --- src/CMakeLists.txt | 4 ++-- src/database/database-postgresql.cpp | 4 ---- src/debug.h | 3 --- src/filesys.cpp | 3 --- src/network/address.cpp | 24 ------------------------ src/network/address.h | 3 --- src/network/socket.cpp | 4 ---- src/porting.h | 8 -------- src/util/string.cpp | 1 - 9 files changed, 2 insertions(+), 52 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a00690b28..66a1b3e66 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -719,7 +719,7 @@ endif() if(MSVC) # Visual Studio - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WIN32_WINNT=0x0601 /D WIN32_LEAN_AND_MEAN") # EHa enables SEH exceptions (used for catching segfaults) set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0") if(CMAKE_SIZEOF_VOID_P EQUAL 4) @@ -762,7 +762,7 @@ else() if(MINGW) set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWIN32_LEAN_AND_MEAN") endif() # Use a safe subset of flags to speed up math calculations: diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp index d84b26b55..54bcf7032 100644 --- a/src/database/database-postgresql.cpp +++ b/src/database/database-postgresql.cpp @@ -23,10 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "database-postgresql.h" #ifdef _WIN32 - // Without this some of the network functions are not found on mingw - #ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif #include #include #else diff --git a/src/debug.h b/src/debug.h index 1faeece8d..9d3e78cbc 100644 --- a/src/debug.h +++ b/src/debug.h @@ -26,9 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #ifdef _WIN32 - #ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif #include #ifdef _MSC_VER #include diff --git a/src/filesys.cpp b/src/filesys.cpp index d610c2311..d91199594 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -41,9 +41,6 @@ namespace fs * Windows * ***********/ -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif #include #include #include diff --git a/src/network/address.cpp b/src/network/address.cpp index cf2e6208d..df1e3b852 100644 --- a/src/network/address.cpp +++ b/src/network/address.cpp @@ -35,10 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #ifdef _WIN32 -// Without this some of the network functions are not found on mingw -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif #include #include #include @@ -149,30 +145,10 @@ void Address::Resolve(const char *name) // IP address -> textual representation std::string Address::serializeString() const { -// windows XP doesnt have inet_ntop, maybe use better func -#ifdef _WIN32 - if (m_addr_family == AF_INET) { - return inet_ntoa(m_address.ipv4); - } else if (m_addr_family == AF_INET6) { - std::ostringstream os; - os << std::hex; - for (int i = 0; i < 16; i += 2) { - u16 section = (m_address.ipv6.s6_addr[i] << 8) | - (m_address.ipv6.s6_addr[i + 1]); - os << section; - if (i < 14) - os << ":"; - } - return os.str(); - } else { - return ""; - } -#else char str[INET6_ADDRSTRLEN]; if (inet_ntop(m_addr_family, (void*) &m_address, str, sizeof(str)) == nullptr) return ""; return str; -#endif } struct in_addr Address::getAddress() const diff --git a/src/network/address.h b/src/network/address.h index 692bf82c5..03528c53b 100644 --- a/src/network/address.h +++ b/src/network/address.h @@ -20,9 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #ifdef _WIN32 -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif #include #include #include diff --git a/src/network/socket.cpp b/src/network/socket.cpp index 786171802..07fcf7062 100644 --- a/src/network/socket.cpp +++ b/src/network/socket.cpp @@ -31,10 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #ifdef _WIN32 -// Without this some of the network functions are not found on mingw -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif #include #include #include diff --git a/src/porting.h b/src/porting.h index cc23e3c62..1617fd644 100644 --- a/src/porting.h +++ b/src/porting.h @@ -23,14 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once -#ifdef _WIN32 - #ifdef _WIN32_WINNT - #undef _WIN32_WINNT - #endif - #define _WIN32_WINNT 0x0501 // We need to do this before any other headers - // because those might include sdkddkver.h which defines _WIN32_WINNT if not already set -#endif - #include #include #include "irrlicht.h" diff --git a/src/util/string.cpp b/src/util/string.cpp index 5c120926c..7e48a182b 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -36,7 +36,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef _WIN32 #include #else - #define _WIN32_WINNT 0x0501 #include #endif