[vlc-devel] [PATCH] configure: check socklen_t as int first

Rémi Denis-Courmont remi at remlab.net
Sun Feb 23 15:17:56 CET 2020


Le maanantaina 17. helmikuuta 2020, 10.19.53 EET KO Myung-Hun a écrit :
> OS/2 socket APIs use int not unsigned int in place of socklen_t. As
> a result, compilation is stopped at function call requiring socklen_t *
> because of type mismatch between int * and unsigned int *.
> ---
>  configure.ac | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 7741ddca55..16eee78456 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -759,8 +759,22 @@ ac_cv_type_socklen_t,
>  #endif]], [[socklen_t len; len = 0;]])],
>  ac_cv_type_socklen_t=yes,
>  ac_cv_type_socklen_t=no)])
> -AS_IF([test "$ac_cv_type_socklen_t" = no],
> - [AC_DEFINE(socklen_t, unsigned int)])
> +AS_IF([test "$ac_cv_type_socklen_t" = no], [
> +  VLC_SAVE_FLAGS
> +  CFLAGS="-Wpointer-sign -Werror"

I doubt that all C compilers support those specific flags, especially the first. 
If you want to match the getpeername() prototype, you should probably use 
_Generic.

> +  AC_COMPILE_IFELSE([
> +    AC_LANG_PROGRAM([[
> +#include <sys/types.h>
> +#ifdef _WIN32
> +# include <winsock2.h>
> +# include <ws2tcpip.h>
> +#else
> +# include <sys/socket.h>
> +#endif
> +]], [[getpeername(0, 0, (int *)0);]])],
> +    AC_DEFINE(socklen_t, int), AC_DEFINE(socklen_t, unsigned int))
> +  VLC_RESTORE_FLAGS
> +])
> 
>  dnl Check for struct sockaddr_storage
>  AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does
> not define.]) dnl ` (fix VIM syntax highlight


-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list