[vlc-devel] [3.0 PATCH 4/5] configure: Check for if_nametoindex in iphlpapi.h

Martin Storsjö martin at martin.st
Mon Apr 6 15:31:36 CEST 2020


If the toolchain defaults to a newer version of windows, this
function is available there, but the previous configure checks
didn't notice it. Force testing with both compiling and linking,
as the function exists in import libraries, but only is visible
in headers since Vista.

On the master branch, the function was taken into use
unconditionally in c0bf5aeefc611f8d1e1ace6111c88956c0a8fa6c.
---
Posted for reference/discussion now, totally ok to defer pushing until
after the pending 3.0 release.
---
 configure.ac      | 15 +++++++++++++--
 src/network/udp.c |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ae581f8c28..370ec9a129 100644
--- a/configure.ac
+++ b/configure.ac
@@ -669,7 +669,7 @@ AC_SEARCH_LIBS(connect, [socket], [
   ])
 ], [
   AS_IF([test "${SYS}" = "mingw32"], [
-    SOCKET_LIBS="-lws2_32"
+    SOCKET_LIBS="-lws2_32 -liphlpapi"
   ])
 ])
 
@@ -680,6 +680,7 @@ AC_SEARCH_LIBS([inet_pton], [nsl], [
 ],, [${SOCKET_LIBS}])
 
 LIBS="${LIBS} ${SOCKET_LIBS}"
+CFLAGS="${CFLAGS} -Werror-implicit-function-declaration"
 AC_LINK_IFELSE([
     AC_LANG_PROGRAM([#ifdef _WIN32
         #include <ws2tcpip.h>
@@ -694,8 +695,18 @@ AC_LINK_IFELSE([
         char dst[[sizeof(struct in_addr)]];
         inet_pton(AF_INET, "127.0.0.1", dst);
     ])],[AC_DEFINE([HAVE_INET_PTON],[1],[Define to 1 if you have inet_pton function])],[AC_LIBOBJ([inet_pton])])
+AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([#ifdef _WIN32
+        #include <iphlpapi.h>
+        #else
+        #include <sys/types.h>
+        #include <sys/socket.h>
+        #include <net/if.h>
+        #endif], [
+        if_nametoindex("");
+    ])],[AC_DEFINE([HAVE_IF_NAMETOINDEX],[1],[Define to 1 if you have if_nametoindex function])])
 AC_CHECK_TYPES([struct if_nameindex],,,[#include <net/if.h>])
-AC_CHECK_FUNCS([if_nameindex if_nametoindex])
+AC_CHECK_FUNCS([if_nameindex])
 VLC_RESTORE_FLAGS
 AC_SUBST(SOCKET_LIBS)
 
diff --git a/src/network/udp.c b/src/network/udp.c
index aaee9d88f4..2c1bc722de 100644
--- a/src/network/udp.c
+++ b/src/network/udp.c
@@ -41,6 +41,7 @@
 #ifdef _WIN32
 #   undef EAFNOSUPPORT
 #   define EAFNOSUPPORT WSAEAFNOSUPPORT
+#   include <iphlpapi.h>
 #else
 #   include <unistd.h>
 #   ifdef HAVE_NET_IF_H
-- 
2.17.1



More information about the vlc-devel mailing list