[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
iconv-h: fix error due to const in declaration
From: |
Bruno Haible |
Subject: |
iconv-h: fix error due to const in declaration |
Date: |
Sat, 27 Nov 2010 04:12:26 +0100 |
User-agent: |
KMail/1.9.9 |
On Solaris 11 Express from this month I'm seeing this compilation failure of
test-iconv-h-c++:
g++ -DHAVE_CONFIG_H -I. -DGNULIB_STRICT_CHECKING=1 -I. -I. -I.. -I./..
-I../gllib -I./../gllib -Wall -MT test-iconv-h-c++.o -MD -MP -MF
.deps/test-iconv-h-c++.Tpo -c -o test-iconv-h-c++.o test-iconv-h-c++.cc
In file included from test-iconv-h-c++.cc:23:
../gllib/iconv.h:394: error: invalid conversion from `size_t (*)(_iconv_info*,
const char**, size_t*, char**, size_t*)' to `size_t (*)(_iconv_info*, char**,
size_t*, char**, size_t*)'
test-iconv-h-c++.cc:35: error: invalid conversion from `size_t
(*)(_iconv_info*, char**, size_t*, char**, size_t*)' to `size_t
(*)(_iconv_info*, const char**, size_t*, char**, size_t*)'
test-iconv-h-c++.cc:32: warning: 'signature_check33' defined but not used
make[4]: *** [test-iconv-h-c++.o] Error 1
The reason is that on this system, with the given CPPFLAGS, the iconv()
declaration has 'const'. But ICONV_CONST is only defined as C macro in
<config.h>, not as AC_SUBSTed variable, hence the substituted value is
empty. This fixes it.
2010-11-26 Bruno Haible <address@hidden>
iconv-h: Fix test-iconv-h-c++ failure on Solaris 11 2010-11.
* lib/iconv.in.h (iconv_open, iconv, iconv_close): Define only if the
'iconv' module is present.
(ICONV_CONST): New macro.
* m4/iconv_h.m4 (gl_ICONV_H_DEFAULTS): Initialize GNULIB_ICONV and
ICONV_CONST.
* m4/iconv.m4 (AM_ICONV): If the gnulib module 'iconv-h' is present,
set ICONV_CONST.
* m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN_UTF): Don't set ICONV_CONST
here.
* modules/iconv (configure.ac): Invoke gl_ICONV_MODULE_INDICATOR.
* modules/iconv-h (Makefile.am): Substitute GNULIB_ICONV.
* tests/test-iconv-h.c (ICONV_CONST): Don't define here.
* tests/test-iconv-h-c++.cc (ICONV_CONST): Don't define here.
(iconv_open, iconv, iconv_close): Test only if the 'iconv' module is
present.
--- lib/iconv.in.h.orig Sat Nov 27 03:58:46 2010
+++ lib/iconv.in.h Sat Nov 27 00:41:19 2010
@@ -36,22 +36,24 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-#if @REPLACE_ICONV_OPEN@
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV_OPEN@
/* An iconv_open wrapper that supports the IANA standardized encoding names
("ISO-8859-1" etc.) as far as possible. */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define iconv_open rpl_iconv_open
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define iconv_open rpl_iconv_open
+# endif
_GL_FUNCDECL_RPL (iconv_open, iconv_t,
(const char *tocode, const char *fromcode)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (iconv_open, iconv_t,
(const char *tocode, const char *fromcode));
-#else
+# else
_GL_CXXALIAS_SYS (iconv_open, iconv_t,
(const char *tocode, const char *fromcode));
-#endif
+# endif
_GL_CXXALIASWARN (iconv_open);
+#endif
#if @REPLACE_ICONV_UTF@
/* Special constants for supporting UTF-{16,32}{BE,LE} encodings.
@@ -66,10 +68,11 @@
# define _ICONV_UTF32LE_UTF8 (iconv_t)(-168)
#endif
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define iconv rpl_iconv
-# endif
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define iconv rpl_iconv
+# endif
_GL_FUNCDECL_RPL (iconv, size_t,
(iconv_t cd,
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
@@ -78,24 +81,30 @@
(iconv_t cd,
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft));
-#else
+# else
_GL_CXXALIAS_SYS (iconv, size_t,
(iconv_t cd,
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft));
-#endif
+# endif
_GL_CXXALIASWARN (iconv);
-
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define iconv_close rpl_iconv_close
+# ifndef ICONV_CONST
+# define ICONV_CONST @ICONV_CONST@
# endif
+#endif
+
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define iconv_close rpl_iconv_close
+# endif
_GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd));
_GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd));
-#else
+# else
_GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd));
-#endif
+# endif
_GL_CXXALIASWARN (iconv_close);
+#endif
#endif /* _GL_ICONV_H */
--- m4/iconv.m4.orig Sat Nov 27 03:58:46 2010
+++ m4/iconv.m4 Sat Nov 27 01:55:24 2010
@@ -1,4 +1,4 @@
-# iconv.m4 serial 15 (gettext-0.18.2)
+# iconv.m4 serial 16 (gettext-0.18.2)
dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -252,5 +252,12 @@
$am_cv_proto_iconv])
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
[Define as const if the declaration of iconv() needs const.])
+ dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
+ m4_ifdef([gl_ICONV_H_DEFAULTS],
+ [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
+ if test -n "$am_cv_proto_iconv_arg1"; then
+ ICONV_CONST="const"
+ fi
+ ])
fi
])
--- m4/iconv_h.m4.orig Sat Nov 27 03:58:46 2010
+++ m4/iconv_h.m4 Sat Nov 27 01:52:07 2010
@@ -1,4 +1,4 @@
-# iconv_h.m4 serial 6
+# iconv_h.m4 serial 7
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,9 @@
AC_DEFUN([gl_ICONV_H_DEFAULTS],
[
+ GNULIB_ICONV=0; AC_SUBST([GNULIB_ICONV])
dnl Assume proper GNU behavior unless another module says otherwise.
+ ICONV_CONST=; AC_SUBST([ICONV_CONST])
REPLACE_ICONV=0; AC_SUBST([REPLACE_ICONV])
REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN])
REPLACE_ICONV_UTF=0; AC_SUBST([REPLACE_ICONV_UTF])
--- m4/iconv_open.m4.orig Sat Nov 27 03:58:46 2010
+++ m4/iconv_open.m4 Sat Nov 27 01:55:27 2010
@@ -1,4 +1,4 @@
-# iconv_open.m4 serial 9
+# iconv_open.m4 serial 10
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -52,12 +52,6 @@
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_REQUIRE([gl_ICONV_H_DEFAULTS])
if test "$am_cv_func_iconv" = yes; then
- if test -n "$am_cv_proto_iconv_arg1"; then
- ICONV_CONST="const"
- else
- ICONV_CONST=
- fi
- AC_SUBST([ICONV_CONST])
AC_CACHE_CHECK([whether iconv supports conversion between UTF-8 and
UTF-{16,32}{BE,LE}],
[gl_cv_func_iconv_supports_utf],
[
--- modules/iconv.orig Sat Nov 27 03:58:46 2010
+++ modules/iconv Sat Nov 27 00:36:39 2010
@@ -9,6 +9,7 @@
configure.ac:
AM_ICONV
+gl_ICONV_MODULE_INDICATOR([iconv])
Makefile.am:
--- modules/iconv-h.orig Sat Nov 27 03:58:46 2010
+++ modules/iconv-h Sat Nov 27 01:51:40 2010
@@ -26,6 +26,7 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_ICONV_H''@|$(NEXT_ICONV_H)|g' \
+ -e 's|@''GNULIB_ICONV''@|$(GNULIB_ICONV)|g' \
-e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \
-e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
-e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
--- tests/test-iconv-h-c++.cc.orig Sat Nov 27 03:58:46 2010
+++ tests/test-iconv-h-c++.cc Sat Nov 27 00:43:05 2010
@@ -22,20 +22,22 @@
#if HAVE_ICONV
# include <iconv.h>
-# ifndef ICONV_CONST
-# define ICONV_CONST /* empty */
-# endif
-
# include "signature.h"
+#if GNULIB_TEST_ICONV
SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv_open, iconv_t,
(const char *, const char *));
+#endif
+#if GNULIB_TEST_ICONV
SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv, size_t,
(iconv_t, ICONV_CONST char **, size_t *, char **, size_t *));
+#endif
+#if GNULIB_TEST_ICONV
SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv_close, int, (iconv_t));
+#endif
#endif
--- tests/test-iconv-h.c.orig Sat Nov 27 03:58:46 2010
+++ tests/test-iconv-h.c Sat Nov 27 00:42:20 2010
@@ -18,10 +18,6 @@
#if HAVE_ICONV
# include <iconv.h>
-
-# ifndef ICONV_CONST
-# define ICONV_CONST /* empty */
-# endif
#endif
int
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- iconv-h: fix error due to const in declaration,
Bruno Haible <=