]> Savannah Git Hosting - gnulib.git/commitdiff
glob-h: Avoid conflict with preprocessor macros owned by the system.
authorBruno Haible <bruno@clisp.org>
Sun, 6 Jun 2021 22:34:54 +0000 (00:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 6 Jun 2021 22:50:36 +0000 (00:50 +0200)
This fixes a compilation error on DragonFly BSD 6.0.

* lib/glob.in.h: Don't include <libc-config.h>. 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.

ChangeLog
lib/glob.in.h
lib/libc-config.h
modules/glob-h

index a940c622d39fca3e65144302d252f00a360692af..79fc6ff0ddcca511ab6f0fdfafa96552fdc1d244 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-06-06  Bruno Haible  <bruno@clisp.org>
+
+       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 <libc-config.h>. 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  <ldv@altlinux.org>
 
        * tests/test-regex.c (tests): Add test cases for *+ and ** regressions
index 4952666407ba8857081fadaf983555b0b457cedf..dbc5b63ac0f3329f518347c6d8317e7d538b42c7 100644 (file)
@@ -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 <libc-config.h>
-# endif
-
 # include <stddef.h>
 
 /* On some systems, such as AIX 5.1, <sys/stat.h> does a "#define stat stat64".
@@ -81,10 +77,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int);
    rely on 'struct stat'.  */
 # include <sys/stat.h>
 
-# 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
index fabca2fa3e130517dd024a92a45997e9e4fd47cd..f68749fc7435317747b0b855e687f01329211753 100644 (file)
 
    When compiled as part of glibc this is a no-op; when compiled as
    part of Gnulib this includes Gnulib's <config.h> 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 <config.h>
 
index 40df48f130a5853669fb0d3c3e1c0e46c75f5290..0b71fd223978750119e8c198d40612fa220c5fc7 100644 (file)
@@ -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:
 <glob.h>