Commit 424e8991 authored by Steve Lhomme's avatar 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.
parent 1d9905e3
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment