The gnulib CI reports a compilation error on Cygwin:

In file included from ../../gllib/copy-acl.c:27:
./error.h:621:15: warning: 'error_print_progname' redeclared without dllimport 
attribute: previous dllimport ignored [-Wattributes]
  621 | extern void (*error_print_progname) (void);
      |               ^~~~~~~~~~~~~~~~~~~~
./error.h:624:21: warning: 'error_message_count' redeclared without dllimport 
attribute: previous dllimport ignored [-Wattributes]
  624 | extern unsigned int error_message_count;
      |                     ^~~~~~~~~~~~~~~~~~~
./error.h:628:12: warning: 'error_one_per_line' redeclared without dllimport 
attribute: previous dllimport ignored [-Wattributes]
  628 | extern int error_one_per_line;
      |            ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/libintl.h:20,
                 from ../../gllib/gettext.h:26,
                 from ../../gllib/copy-acl.c:28:
/usr/include/libintl.h:1098:14: error: expected identifier or '(' before 'const'
 1098 | extern char *setlocale (int, const char *)
      |              ^~~~~~~~~
/usr/include/libintl.h:1098:14: error: expected ')' before 'setlocale'
 1098 | extern char *setlocale (int, const char *)
      |              ^~~~~~~~~
make[4]: *** [Makefile:12235: copy-acl.o] Error 1


The cause is that on the CI machine, Cygwin's libintl.h got upgraded from
version 0.22.5 to version 0.26, and that contains a declaration of setlocale.
Which conflicts with the macro definition from gnulib's <locale.h> override.

This patch fixes it.


2026-11-16  Bruno Haible  <[email protected]>

        setlocale: Fix conflict with gettext's <libintl.h> on macOS, Windows.
        * lib/locale.in.h (setlocale): Disable macro definition on macOS,
        Cygwin, native Windows.

diff --git a/lib/locale.in.h b/lib/locale.in.h
index e20d4fa5ff..b1b4a46e21 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -293,7 +293,10 @@ _GL_CXXALIAS_RPL (setlocale, const char *,
 # else
 _GL_CXXALIAS_SYS_CAST (setlocale, const char *,
                        (int category, const char *locale));
-#  if !defined setlocale && !defined __cplusplus
+#  if !defined setlocale && !defined __cplusplus \
+      /* Avoid a conflict with GNU gettext's <libintl.h>.  */ \
+      && !((defined __APPLE__ && defined __MACH__) \
+           || defined _WIN32 || defined __CYGWIN__)
 #   define setlocale(...) ((const char *) setlocale (__VA_ARGS__))
 #  endif
 # endif




Reply via email to