[vlc-commits] configure: check if if_nametoindex is available on Windows

Steve Lhomme git at videolan.org
Thu May 28 09:47:13 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr 30 10:53:27 2020 +0200| [b813f909a6bfb6b1e03f6a6029eaa056bf50a121] | 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=b813f909a6bfb6b1e03f6a6029eaa056bf50a121
---

 configure.ac         | 19 +++++++++++++++++++
 include/vlc_fixups.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/configure.ac b/configure.ac
index ea50387801..9d1bfe2c7d 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(NULL);
+        }
+      ]],[[;]])
+    ],[
+      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..42d5b31661 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -454,6 +454,10 @@ struct msghdr
     size_t        msg_controllen;
     int           msg_flags;
 };
+
+# ifndef HAVE_IF_NAMETOINDEX
+#  define if_nametoindex(name)  atoi(name)
+# endif
 #endif
 
 #ifdef _NEWLIB_VERSION



More information about the vlc-commits mailing list