]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
msvc: fix building with `HAVE_INET_NTOP` and MSVC <=1900
authorViktor Szakats <commit@vsz.me>
Tue, 7 Jan 2025 09:48:57 +0000 (10:48 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 7 Jan 2025 13:07:19 +0000 (14:07 +0100)
MSVC 1900 and older is missing a `const` specifier in the `inet_ntop()`
declaration for the second argument. A workaround was in place for it
in cmake, but it didn't cover all necessary versions.

Replace the workaround with a different one, move it to `lib/inet_ntop.c`
and extend to all necessary MSVC versions.

Also add CI jobs for the older MSVC versions: 2013, 2015, 2017.

Closes #15923

CMakeLists.txt
appveyor.yml
lib/inet_ntop.h

index 84252a3109744a95c4fa075a95462fa76f726843..1ede5306fe2100321b4daf73b7fd551b2ab4de82 100644 (file)
@@ -1703,9 +1703,6 @@ if(APPLE)
   check_function_exists("mach_absolute_time" HAVE_MACH_ABSOLUTE_TIME)
 endif()
 check_symbol_exists("inet_ntop" "${CURL_INCLUDES};stdlib.h;string.h" HAVE_INET_NTOP)  # arpa/inet.h
-if(MSVC AND (MSVC_VERSION LESS_EQUAL 1600))
-  set(HAVE_INET_NTOP OFF)
-endif()
 check_symbol_exists("inet_pton" "${CURL_INCLUDES};stdlib.h;string.h" HAVE_INET_PTON)  # arpa/inet.h
 
 check_symbol_exists("fsetxattr" "sys/xattr.h" HAVE_FSETXATTR)
index 8209cd119bdaf1308f9be6ccb5107e7ec5210b0a..4e4be0b5165ea8bb010948a7d7d2f66ffa8d46da 100644 (file)
@@ -61,6 +61,39 @@ environment:
       ENABLE_UNICODE: 'OFF'
       SHARED: 'ON'
       EXAMPLES: 'ON'
+    - job_name: 'CMake, VS2013, Debug, x64, OpenSSL 1.1.1, Build-only'
+      APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015'
+      BUILD_SYSTEM: CMake
+      PRJ_GEN: 'Visual Studio 12 2013'
+      TARGET: '-A x64'
+      PRJ_CFG: Debug
+      OPENSSL: 'ON'
+      SCHANNEL: 'OFF'
+      ENABLE_UNICODE: 'OFF'
+      SHARED: 'ON'
+      TFLAGS: 'skipall'
+    - job_name: 'CMake, VS2015, Debug, x64, OpenSSL 1.1.1, Build-only'
+      APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015'
+      BUILD_SYSTEM: CMake
+      PRJ_GEN: 'Visual Studio 14 2015'
+      TARGET: '-A x64'
+      PRJ_CFG: Debug
+      OPENSSL: 'ON'
+      SCHANNEL: 'OFF'
+      ENABLE_UNICODE: 'OFF'
+      SHARED: 'ON'
+      TFLAGS: 'skipall'
+    - job_name: 'CMake, VS2017, Debug, x64, OpenSSL 1.1.1, Build-only'
+      APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2017'
+      BUILD_SYSTEM: CMake
+      PRJ_GEN: 'Visual Studio 15 2017'
+      TARGET: '-A x64'
+      PRJ_CFG: Debug
+      OPENSSL: 'ON'
+      SCHANNEL: 'OFF'
+      ENABLE_UNICODE: 'OFF'
+      SHARED: 'ON'
+      TFLAGS: 'skipall'
     - job_name: 'CMake, VS2022, Release, x64, OpenSSL 3.3, Shared, Build-tests'
       APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
       BUILD_SYSTEM: CMake
index 206d79c86624ac218d3f6c70962a6fe11962fea7..3b90ed3b47babe67778bebfff14938c5f9668bbe 100644 (file)
@@ -33,8 +33,11 @@ char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size);
 #include <arpa/inet.h>
 #endif
 #ifdef _WIN32
-#define Curl_inet_ntop(af,addr,buf,size) \
-        inet_ntop(af, addr, buf, size)
+#if defined(_MSC_VER) && (_MSC_VER <= 1900)
+#define Curl_inet_ntop(af,addr,buf,size) inet_ntop(af, (void *)addr, buf, size)
+#else
+#define Curl_inet_ntop(af,addr,buf,size) inet_ntop(af, addr, buf, size)
+#endif
 #elif defined(__AMIGA__)
 #define Curl_inet_ntop(af,addr,buf,size) \
         (char *)inet_ntop(af, (void *)addr, (unsigned char *)buf, \