Werner LEMBERG <w...@gnu.org> writes: >>> Given that the intention of the above test is to check if the iconv >>> function works properly, maybe a workaround would be to use the >>> fixed prototype of iconv (as attached)? >> >> Sorry, that was obviously wrong. The other idea is to suppress the >> error with a pragma, but I guess it would be better to actually >> check the prototype in AM_ICONV_LINK. > > What about using m4_foreach, running the link tests with and without > `const'?
Thanks for the tip. The attached patch seems to work with both cases. Regards, -- Daiki Ueno
>From fb53151f8c9456f186b2f192c02bd45e85c35476 Mon Sep 17 00:00:00 2001 From: Daiki Ueno <u...@gnu.org> Date: Tue, 21 Oct 2014 18:07:00 +0900 Subject: [PATCH] iconv: avoid false detection of non-working iconv The INBUF/OUTBUF arguments of iconv can be either 'const char **' or 'char **'. If CC is g++, the difference causes a compile error and thus leads to a false detection of non-working iconv. Reported by Eli Zaretskii and Werner LEMBERG in: <https://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00023.html>. * m4/iconv.m4 (AM_ICONV_LINK): Try all possible argument types of iconv. Bump serial number. --- ChangeLog | 11 +++++++++++ m4/iconv.m4 | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23234b7..49639fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2014-10-21 Daiki Ueno <u...@gnu.org> + + iconv: avoid false detection of non-working iconv + The INBUF/OUTBUF arguments of iconv can be either 'const char **' + or 'char **'. If CC is g++, the difference causes a compile error + and thus leads to a false detection of non-working iconv. + Reported by Eli Zaretskii and Werner LEMBERG in: + <https://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00023.html>. + * m4/iconv.m4 (AM_ICONV_LINK): Try all possible argument types of + iconv. Bump serial number. + 2014-10-18 Paul Eggert <egg...@cs.ucla.edu> symlinkat: port to AIX 7.1 diff --git a/m4/iconv.m4 b/m4/iconv.m4 index 4b29c5f..9726a33 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 @@ -1,4 +1,4 @@ -# iconv.m4 serial 18 (gettext-0.18.2) +# iconv.m4 serial 19 (gettext-0.18.2) dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -72,13 +72,16 @@ AC_DEFUN([AM_ICONV_LINK], if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + am_cv_func_iconv_works=no + m4_foreach([gl_iconv_buf_t], [[char **], [const char **]], [ + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <iconv.h> #include <string.h> -int main () -{ - int result = 0; + +typedef] gl_iconv_buf_t [gl_iconv_buf_t;]], + [[int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { @@ -92,8 +95,8 @@ int main () char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); + (gl_iconv_buf_t) &inptr, &inbytesleft, + (gl_iconv_buf_t) &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); @@ -112,8 +115,8 @@ int main () char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); + (gl_iconv_buf_t) &inptr, &inbytesleft, + (gl_iconv_buf_t) &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); @@ -131,8 +134,8 @@ int main () char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); + (gl_iconv_buf_t) &inptr, &inbytesleft, + (gl_iconv_buf_t) &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); @@ -151,8 +154,8 @@ int main () char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); + (gl_iconv_buf_t) &inptr, &inbytesleft, + (gl_iconv_buf_t) &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); @@ -171,18 +174,15 @@ int main () && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; -}]])], - [am_cv_func_iconv_works=yes], - [am_cv_func_iconv_works=no], - [ -changequote(,)dnl - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -changequote([,])dnl - ]) - LIBS="$am_save_LIBS" +]])], + [am_cv_func_iconv_works=yes], , [am_cv_func_iconv_works=cross])]) + if test "$am_cv_func_iconv_works" = "cross"; then + case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac + fi + LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; -- 1.9.3