# HG changeset patch # User Bruno Haible # Date 1268006094 -3600 # Node ID fecbba7601e986ecb2c78778a4fecb629a8f895b # Parent 82b0c98fe7aa220458510e89f08241a947ceb6c1 glob: Avoid #define replacements in C++ mode. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-03-07 Bruno Haible + 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. diff --git a/lib/glob.in.h b/lib/glob.in.h --- a/lib/glob.in.h +++ b/lib/glob.in.h @@ -45,8 +45,12 @@ # 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 @@ -64,4 +68,24 @@ /* 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 */ diff --git a/modules/glob b/modules/glob --- a/modules/glob +++ b/modules/glob @@ -11,6 +11,7 @@ Depends-on: alloca arg-nonnull +c++defs d-type dirfd extensions @@ -22,6 +23,7 @@ strdup sys_stat unistd +warn-on-use malloc-posix configure.ac: @@ -32,11 +34,13 @@ # We need the following in order to create 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 $@