]> Savannah Git Hosting - gnulib.git/commitdiff
configmake: Avoid namespace pollution issue on mingw.
authorEric Blake <eblake@redhat.com>
Thu, 8 Aug 2019 03:03:31 +0000 (22:03 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 8 Aug 2019 13:47:18 +0000 (08:47 -0500)
Mingw includes a header that declares an enum typedef named DATADIR,
pulled in when including <winsock2.h>; compilation fails if DATADIR
has already been defined as a macro expanding to a string prior to
that inclusion.  Although the configmake module documents that it
should generally be included only after system headers, it is just as
easy to make configmake.h robust to this particular issue by including
the system header first if it exists.

* modules/configmake (Makefile.am): If the project uses
<winsock2.h>, include that header before defining DATADIR.
Reported by libvirt: https://lists.gnu.org/archive/html/bug-gnulib/2019-07/msg00089.html

ChangeLog
modules/configmake

index 644330370700fd7f4517a95ed1fc0cb13cf0b691..35f870abeffc55af8c68862073b85e845e6beb0c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-08  Eric Blake  <eblake@redhat.com>
+
+       configmake: Avoid namespace pollution issue on mingw.
+       * modules/configmake (Makefile.am): If the project uses
+       <winsock2.h>, include that header before defining DATADIR.
+
 2019-07-28  Bruno Haible  <bruno@clisp.org>
 
        mbrtowc tests: Fix regression on mingw (regression from 2018-02-24).
index 5a60f4f8078e157c43c9eaf878ad06ef2a14710f..d387adc90c105195a22b91e1d83c167cebe584b9 100644 (file)
@@ -17,6 +17,9 @@ Makefile.am:
 configmake.h: Makefile
        $(AM_V_GEN)rm -f $@-t && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         echo '#if HAVE_WINSOCK2_H'; \
+         echo '# include <winsock2.h> /* avoid mingw pollution on DATADIR */'; \
+         echo '#endif'; \
          echo '#define PREFIX "$(prefix)"'; \
          echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
          echo '#define BINDIR "$(bindir)"'; \