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

index c0470ab..75388bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+       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.
+       (glob, globfree, glob_pattern_p): In C++, define a namespaced alias
+       symbol.
+       * modules/glob (Depends-on): Add c++defs, warn-on-use.
+       (Makefile.am): Update glob.h rule.
+
        fcntl-h: Avoid #define replacements in C++ mode.
        * lib/fcntl.in.h: Include c++defs.h.
        (fcntl, open, openat): In C++, define a namespaced alias symbol.
index 8f32a79..7bd994d 100644 (file)
 # define __THROW
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
 #ifndef __size_t
 # define __size_t       size_t
 #endif
 /* Now the standard GNU C Library header should work.  */
 #include "glob-libc.h"
 
+__BEGIN_DECLS
+typedef int (*_gl_glob_errfunc_fn) (const char *, int);
+__END_DECLS
+
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# undef glob
+# undef globfree
+# undef glob_pattern_p
+_GL_CXXALIAS_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags,
+                              _gl_glob_errfunc_fn __errfunc,
+                              glob_t *_Restrict_ __pglob));
+_GL_CXXALIAS_RPL (globfree, void, (glob_t *__pglob));
+_GL_CXXALIAS_RPL (glob_pattern_p, int, (const char *__pattern, int __quote));
+# if 0  /* The C function name is rpl_glob, not glob.  */
+_GL_CXXALIASWARN (glob);
+_GL_CXXALIASWARN (globfree);
+_GL_CXXALIASWARN (glob_pattern_p);
+# endif
+#endif
+
 #endif /* _GL_GLOB_H */
index 204ba48..0caaeef 100644 (file)
@@ -11,6 +11,7 @@ m4/glob.m4
 Depends-on:
 alloca
 arg-nonnull
+c++defs
 d-type
 dirfd
 extensions
@@ -22,6 +23,7 @@ stdbool
 strdup
 sys_stat
 unistd
+warn-on-use
 malloc-posix
 
 configure.ac:
@@ -32,11 +34,13 @@ BUILT_SOURCES += $(GLOB_H)
 
 # We need the following in order to create <glob.h> when the system
 # doesn't have one that works with the given compiler.
-glob.h: glob.in.h $(ARG_NONNULL_H)
+glob.h: glob.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|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|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)/glob.in.h; \
        } > $@-t && \
        mv -f $@-t $@