Hello, Werner LEMBERG <w...@gnu.org> writes:
> Eli reported a failure in the detection code of iconv on MinGW while > building groff: > > conftest.cpp:62:51: error: invalid conversion from 'char**' to 'const > char**' [-fpermissive] > In file included from conftest.cpp:43:0: > d:\usr\bin\../lib/gcc/mingw32/4.7.2/../../../../include/iconv.h:83:15: > error: initializing argument 2 of 'size_t libiconv(libiconv_t, const char**, > size_t*, char**, size_t*)' [-fpermissive] [...] > It seems to me that the problem is a bug in gnulib's `iconv.m4' > serialĀ 18 file: Looking into this file I see that the body of > `AM_ICONV' calls the macro `AM_ICONV_LINK' before the test that checks > whether `const' is needed. Obviously, it should be vice versa. 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)? I'm still not able to reproduce the original error on my MinGW environment, though. Regards, -- Daiki Ueno
>From 39e7957f1f724ae39524a82c230441df2557686c Mon Sep 17 00:00:00 2001 From: Daiki Ueno <u...@gnu.org> Date: Tue, 21 Oct 2014 13:01:10 +0900 Subject: [PATCH] iconv: avoid false link error with g++ and libiconv 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): Use the fixed prototype of the iconv function while checking if iconv works properly. --- ChangeLog | 8 ++++++++ m4/iconv.m4 | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 23234b7..852005c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-10-21 Daiki Ueno <u...@gnu.org> + + iconv: avoid false link error with g++ and libiconv + 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): Use the fixed prototype of the + iconv function while checking if iconv works properly. + 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..1aa41f3 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, @@ -76,6 +76,18 @@ AC_DEFUN([AM_ICONV_LINK], [AC_LANG_SOURCE([[ #include <iconv.h> #include <string.h> + +/* We are not really interested in whether INPTR and OUTPTR need + 'const' qualifier here. Use the fixed prototype to avoid false + link error when compiled with -fpermissive or g++. */ +#undef iconv +extern +#ifdef __cplusplus +"C" +#endif +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, + char * *outbuf, size_t *outbytesleft); + int main () { int result = 0; -- 1.9.3