bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] configmake: Avoid namespace pollution issue on mingw.


From: Eric Blake
Subject: [PATCH] configmake: Avoid namespace pollution issue on mingw.
Date: Thu, 8 Aug 2019 07:04:24 -0500

Mingw includes a header that declares a struct 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
---

I've tested that this will fix the issue originally reported by
libvirt.  Bruno's suggestion of renaming configmake.h's version to
something like MAKEVAR_DATADIR would also work, but if we did that, it
would be better to uniformly rename all of configmake.h's macros (and
that is much more invasive to the existing users of configmake).

 ChangeLog          | 6 ++++++
 modules/configmake | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 644330370..35f870abe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-08  Eric Blake  <address@hidden>
+
+       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  <address@hidden>

        mbrtowc tests: Fix regression on mingw (regression from 2018-02-24).
diff --git a/modules/configmake b/modules/configmake
index 5a60f4f80..0074071fc 100644
--- a/modules/configmake
+++ b/modules/configmake
@@ -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)"'; \
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]