[vlc-commits] configure: Check for if_nametoindex in iphlpapi.h

Martin Storsjö git at videolan.org
Wed Apr 8 23:58:10 CEST 2020


vlc/vlc-3.0 | branch: master | Martin Storsjö <martin at martin.st> | Fri Feb 28 10:35:16 2020 +0200| [b3afca2a50e68bb49718598a7489947ccbf37d8b] | committer: Martin Storsjo

configure: Check for if_nametoindex in iphlpapi.h

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.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b3afca2a50e68bb49718598a7489947ccbf37d8b
---

 configure.ac      | 15 +++++++++++++--
 src/network/udp.c |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 074d40bb0e..0949ea4442 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
         # if _WIN32_WINNT < 0x600
@@ -693,8 +694,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



More information about the vlc-commits mailing list