[vlc-devel] [3.0 PATCH 2/2] configure: Check for if_nametoindex in iphlpapi.h
Martin Storsjö
martin at martin.st
Thu Apr 2 16:32:11 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.
---
configure.ac | 15 +++++++++++++--
src/network/udp.c | 1 +
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 80bb46483b..1f54085cae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -666,7 +666,7 @@ AC_SEARCH_LIBS(connect, [socket], [
])
], [
AS_IF([test "${SYS}" = "mingw32"], [
- SOCKET_LIBS="-lws2_32"
+ SOCKET_LIBS="-lws2_32 -liphlpapi"
])
])
@@ -677,6 +677,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>
@@ -691,8 +692,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.11.0
More information about the vlc-devel
mailing list