From: Bruno Haible Date: Mon, 8 Mar 2010 00:00:03 +0000 (+0100) Subject: iconv-h: Avoid #define replacements in C++ mode. X-Git-Tag: v0.1~4554 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=db71e106899212c97345f4eb173b53ca995eb88f;p=gnulib.git iconv-h: Avoid #define replacements in C++ mode. --- diff --git a/ChangeLog b/ChangeLog index 75388bc18..61862eb56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2010-03-07 Bruno Haible + iconv-h: Avoid #define replacements in C++ mode. + * lib/iconv.in.h: Include c++defs.h, warn-on-use.h. + (iconv_open, iconv, iconv_close): In C++, define a namespaced alias + symbol. + * m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN): Invoke gl_REPLACE_ICONV_H + whenever iconv is present. + * modules/iconv-h (Depends-on): Add c++defs, warn-on-use. + (Makefile.am): Update iconv.h rule. + glob: Avoid #define replacements in C++ mode. * lib/glob.in.h: Include c++defs.h, warn-on-use.h. (_gl_glob_errfunc_fn): New type. diff --git a/lib/iconv.in.h b/lib/iconv.in.h index b75ae2452..c8f516b06 100644 --- a/lib/iconv.in.h +++ b/lib/iconv.in.h @@ -28,20 +28,29 @@ #ifndef _GL_ICONV_H #define _GL_ICONV_H +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + /* The definition of _GL_ARG_NONNULL is copied here. */ -#ifdef __cplusplus -extern "C" { -#endif +/* The definition of _GL_WARN_ON_USE is copied here. */ #if @REPLACE_ICONV_OPEN@ /* An iconv_open wrapper that supports the IANA standardized encoding names ("ISO-8859-1" etc.) as far as possible. */ -# define iconv_open rpl_iconv_open -extern iconv_t iconv_open (const char *tocode, const char *fromcode) - _GL_ARG_NONNULL ((1, 2)); +# 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 +_GL_CXXALIAS_SYS (iconv_open, iconv_t, + (const char *tocode, const char *fromcode)); #endif +_GL_CXXALIASWARN (iconv_open); #if @REPLACE_ICONV_UTF@ /* Special constants for supporting UTF-{16,32}{BE,LE} encodings. @@ -57,18 +66,36 @@ extern iconv_t iconv_open (const char *tocode, const char *fromcode) #endif #if @REPLACE_ICONV@ -# define iconv rpl_iconv -extern size_t iconv (iconv_t cd, - @ICONV_CONST@ char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft); -# define iconv_close rpl_iconv_close -extern int iconv_close (iconv_t cd); +# 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, + char **outbuf, size_t *outbytesleft)); +_GL_CXXALIAS_RPL (iconv, size_t, + (iconv_t cd, + @ICONV_CONST@ char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft)); +#else +_GL_CXXALIAS_SYS (iconv, size_t, + (iconv_t cd, + @ICONV_CONST@ char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft)); #endif +_GL_CXXALIASWARN (iconv); - -#ifdef __cplusplus -} +#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 +_GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd)); #endif +_GL_CXXALIASWARN (iconv_close); + #endif /* _GL_ICONV_H */ #endif /* _GL_ICONV_H */ diff --git a/m4/iconv_open.m4 b/m4/iconv_open.m4 index d6f44fb37..60f62ca51 100644 --- a/m4/iconv_open.m4 +++ b/m4/iconv_open.m4 @@ -1,4 +1,4 @@ -# iconv_open.m4 serial 6 +# iconv_open.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, @@ -10,6 +10,8 @@ AC_DEFUN([gl_FUNC_ICONV_OPEN], AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_ICONV_H_DEFAULTS]) if test "$am_cv_func_iconv" = yes; then + dnl Provide the override, for the sake of the C++ aliases. + gl_REPLACE_ICONV_H dnl Test whether iconv_open accepts standardized encoding names. dnl We know that GNU libiconv and GNU libc do. AC_EGREP_CPP([gnu_iconv], [ diff --git a/modules/iconv-h b/modules/iconv-h index 0a3d0766d..b0fd1371a 100644 --- a/modules/iconv-h +++ b/modules/iconv-h @@ -7,7 +7,9 @@ m4/iconv_h.m4 Depends-on: include_next +c++defs arg-nonnull +warn-on-use configure.ac: gl_ICONV_H @@ -17,7 +19,7 @@ BUILT_SOURCES += $(ICONV_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. -iconv.h: iconv.in.h $(ARG_NONNULL_H) +iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -27,7 +29,9 @@ iconv.h: iconv.in.h $(ARG_NONNULL_H) -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/iconv.in.h; \ } > $@-t && \ mv $@-t $@