[vlc-commits] configure: check if if_nametoindex is available on Windows
Steve Lhomme
git at videolan.org
Fri Jun 5 15:02:39 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr 30 10:53:27 2020 +0200| [424e8991d357e948627bd8ce8872ce7e8a5de6a7] | committer: Steve Lhomme
configure: check if if_nametoindex is available on Windows
It may link with iphlpapi but be forbidden in UWP.
This test relies on the fact that -Werror-implicit-function-declaration works
in the compiler. And that's why it's done after it's enabled.
It's only used for the --miface option to set the preferred multicast interface.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=424e8991d357e948627bd8ce8872ce7e8a5de6a7
---
configure.ac | 19 +++++++++++++++++++
include/vlc_fixups.h | 8 ++++++++
2 files changed, 27 insertions(+)
diff --git a/configure.ac b/configure.ac
index ea50387801..3f6e91a188 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1048,9 +1048,28 @@ dnl
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond], [CXXFLAGS])
+dnl -Werror-implicit-function-declaration is used for the if_nametoindex detection with winstore
AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -Wmultistatement-macros], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-pipe], [CFLAGS])
+dnl UWP forbidden checks
+AS_IF([test "${SYS}" = "mingw32"], [
+ AC_MSG_CHECKING(for if_nametoindex availability)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[#include <windows.h>
+ #include <iphlpapi.h>
+ static void test (void) {
+ if_nametoindex("");
+ }
+ ]],[[;]])
+ ],[
+ AC_MSG_RESULT([present])
+ AC_DEFINE([HAVE_IF_NAMETOINDEX], [1], [Define to 1 if you have if_nametoindex function])
+ ],[
+ AC_MSG_RESULT([not present])
+ ])
+])
+
dnl
dnl Debugging mode
dnl
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 25c7de473e..17fa3ed09a 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -454,6 +454,14 @@ struct msghdr
size_t msg_controllen;
int msg_flags;
};
+
+# ifndef HAVE_IF_NAMETOINDEX
+# include <stdlib.h> /* a define may change from the real atoi declaration */
+static inline int if_nametoindex(const char *name)
+{
+ return atoi(name);
+}
+# endif
#endif
#ifdef _NEWLIB_VERSION
More information about the vlc-commits
mailing list