From: Bruno Haible Date: Sun, 6 Jun 2021 22:34:54 +0000 (+0200) Subject: glob-h: Avoid conflict with preprocessor macros owned by the system. X-Git-Tag: v1.0~2848 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a5b7194c670089046d9f22c220fea2afc3985c2a;p=gnulib.git glob-h: Avoid conflict with preprocessor macros owned by the system. This fixes a compilation error on DragonFly BSD 6.0. * lib/glob.in.h: Don't include . Don't define __USE_GNU. Include glob-libc.gl.h instead of glob-libc.h. * modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from glob-libc.h. * lib/libc-config.h: Add comment. --- diff --git a/ChangeLog b/ChangeLog index a940c622d3..79fc6ff0dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2021-06-06 Bruno Haible + + glob-h: Avoid conflict with preprocessor macros owned by the system. + This fixes a compilation error on DragonFly BSD 6.0. + * lib/glob.in.h: Don't include . Don't define __USE_GNU. + Include glob-libc.gl.h instead of glob-libc.h. + * modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from + glob-libc.h. + * lib/libc-config.h: Add comment. + 2021-06-06 Dmitry V. Levin * tests/test-regex.c (tests): Add test cases for *+ and ** regressions diff --git a/lib/glob.in.h b/lib/glob.in.h index 4952666407..dbc5b63ac0 100644 --- a/lib/glob.in.h +++ b/lib/glob.in.h @@ -70,10 +70,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); /* Preparations for including the standard GNU C Library header. */ -# ifndef __attribute_maybe_unused__ -# include -# endif - # include /* On some systems, such as AIX 5.1, does a "#define stat stat64". @@ -81,10 +77,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); rely on 'struct stat'. */ # include -# ifndef __USE_GNU -# define __USE_GNU 1 -# endif - # if @REPLACE_GLOB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define glob rpl_glob @@ -102,7 +94,7 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); /* Now the standard GNU C Library header should work. */ -# include "glob-libc.h" +# include "glob-libc.gl.h" #endif diff --git a/lib/libc-config.h b/lib/libc-config.h index fabca2fa3e..f68749fc74 100644 --- a/lib/libc-config.h +++ b/lib/libc-config.h @@ -28,7 +28,10 @@ When compiled as part of glibc this is a no-op; when compiled as part of Gnulib this includes Gnulib's and defines macros - that glibc library code would normally assume. */ + that glibc library code would normally assume. + + Note: This header file MUST NOT be included by public header files + of Gnulib. */ #include diff --git a/modules/glob-h b/modules/glob-h index 40df48f130..0b71fd2239 100644 --- a/modules/glob-h +++ b/modules/glob-h @@ -51,6 +51,23 @@ glob.h: $(top_builddir)/config.status endif MOSTLYCLEANFILES += glob.h glob.h-t +BUILT_SOURCES += glob-libc.gl.h + +glob-libc.gl.h: glob-libc.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e '/__BEGIN_DECLS/{ s/__BEGIN_DECLS/#ifdef __cplusplus%extern "C" {%#endif/; y/%/\n/; }' \ + -e '/__END_DECLS/{ s/__END_DECLS/#ifdef __cplusplus%}%#endif/; y/%/\n/; }' \ + -e 's|__THROW||g' \ + -e 's|defined __USE_MISC|1|' \ + -e 's|ifdef __USE_GNU|if 1|' \ + -e 's|ifdef __USE_LARGEFILE64|if 0|' \ + < $(srcdir)/glob-libc.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += glob-libc.gl.h glob-libc.gl.h-t + + Include: