langinfo: Avoid #define replacements in C++ mode.
authorBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 00:02:55 +0000 (01:02 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 02:11:10 +0000 (03:11 +0100)
ChangeLog
lib/langinfo.in.h
modules/langinfo

index 61862eb..6ae4a29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+       langinfo: Avoid #define replacements in C++ mode.
+       * lib/langinfo.in.h: Include c++defs.h.
+       (nl_langinfo): In C++, define a namespaced alias symbol.
+       * modules/langinfo (Depends-on): Add c++defs.
+       (Makefile.am): Update langinfo.h rule.
+
        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
index 3d3e2ba..54fa1af 100644 (file)
@@ -123,14 +123,12 @@ typedef int nl_item;
 
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 /* Declare overridden functions.  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 
 /* Return a piece of locale dependent information.
    Note: The difference between nl_langinfo (CODESET) and locale_charset ()
@@ -138,12 +136,19 @@ extern "C" {
 
 #if @GNULIB_NL_LANGINFO@
 # if @REPLACE_NL_LANGINFO@
-#  undef nl_langinfo
-#  define nl_langinfo rpl_nl_langinfo
-# endif
-# if !@HAVE_NL_LANGINFO@ || @REPLACE_NL_LANGINFO@
-extern char *nl_langinfo (nl_item item);
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef nl_langinfo
+#   define nl_langinfo rpl_nl_langinfo
+#  endif
+_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item));
+_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
+# else
+#  if !@HAVE_NL_LANGINFO@
+_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
+#  endif
+_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
 # endif
+_GL_CXXALIASWARN (nl_langinfo);
 #elif defined GNULIB_POSIXCHECK
 # undef nl_langinfo
 # if HAVE_RAW_DECL_NL_LANGINFO
@@ -153,10 +158,5 @@ _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
 #endif
 
 
-#ifdef __cplusplus
-}
-#endif
-
-
 #endif /* _GL_LANGINFO_H */
 #endif /* _GL_LANGINFO_H */
index 07d4e47..c7f545e 100644 (file)
@@ -8,6 +8,7 @@ m4/langinfo_h.m4
 Depends-on:
 extensions
 include_next
+c++defs
 warn-on-use
 
 configure.ac:
@@ -18,7 +19,7 @@ BUILT_SOURCES += langinfo.h
 
 # We need the following in order to create an empty placeholder for
 # <langinfo.h> when the system doesn't have one.
-langinfo.h: langinfo.in.h $(WARN_ON_USE_H)
+langinfo.h: langinfo.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f $@-t $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
@@ -30,6 +31,7 @@ langinfo.h: langinfo.in.h $(WARN_ON_USE_H)
              -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
              -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
              -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/langinfo.in.h; \
        } > $@-t && \