]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Improve support for clang on native Windows.
authorBruno Haible <bruno@clisp.org>
Sun, 11 Jan 2026 00:21:58 +0000 (01:21 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Jan 2026 00:21:58 +0000 (01:21 +0100)
Reported by Kirill Makurin <maiddaisuki@outlook.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2026-01/msg00021.html>.

* libtextstyle/gnulib-local/lib/ostream.oo.h (ostream_printf, ostream_vprintf):
Treat clang like GCC.
* gettext-runtime/libasprintf/vasprintf.h (__attribute__, __format__,
__printf__): Likewise.
* gettext-runtime/libasprintf/autosprintf.in.h (_AUTOSPRINTF_ATTRIBUTE_FORMAT):
Likewise.
* gettext-tools/src/format.h (formatstring_error_logger_t): Likewise.
* gettext-tools/src/if-error.h (if_error, if_verror): Likewise.
* gettext-tools/src/msgl-check.c (formatstring_error_logger): Likewise.
* gettext-tools/src/msgl-merge.c (silent_error_logger): Likewise.
* gettext-tools/src/po-error.h (__attribute__, __format__, __printf__, po_error,
po_error_at_line): Likewise.
* gettext-tools/src/read-po-lex.h (__attribute__, __format__, __printf__):
Likewise.
* gettext-tools/src/xg-check.c (formatstring_error_logger): Likewise.
* gettext-tools/libgettextpo/gettext-po.in.h (struct po_error_handler):
Likewise.

gettext-runtime/libasprintf/autosprintf.in.h
gettext-runtime/libasprintf/vasprintf.h
gettext-tools/libgettextpo/gettext-po.in.h
gettext-tools/src/format.h
gettext-tools/src/if-error.h
gettext-tools/src/msgl-check.c
gettext-tools/src/msgl-merge.c
gettext-tools/src/po-error.h
gettext-tools/src/read-po-lex.h
gettext-tools/src/xg-check.c
libtextstyle/gnulib-local/lib/ostream.oo.h

index de048dfa9b624f3af4032ba17aad636ef4d6343b..a73dc0b3bd704e943d496ef8ce7972c9f2fe5999 100644 (file)
@@ -1,5 +1,5 @@
 /* Class autosprintf - formatted output to an ostream.
-   Copyright (C) 2002, 2012-2016 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2012-2026 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
 #ifndef _AUTOSPRINTF_H
 #define _AUTOSPRINTF_H
 
-/* This feature is available in gcc versions 2.5 and later.  */
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+/* This feature is available in gcc versions 2.5 and later and in clang.  */
+#if !((__GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || defined __clang__) && !__STRICT_ANSI__)
 # define _AUTOSPRINTF_ATTRIBUTE_FORMAT() /* empty */
 #else
-/* The __-protected variants of 'format' and 'printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+/* The __-protected variants of 'format' and 'printf' attributes are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later and in clang.  */
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
 #  define _AUTOSPRINTF_ATTRIBUTE_FORMAT() \
   __attribute__ ((__format__ (__printf__, 2, 3)))
 # else
index 2b65c72171f429cf4d1e64d6ed055430d81fc1de..1e0290c12b55e89ead1287b72985afc03a3ba325 100644 (file)
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 2002-2003, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2012-2026 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
 #include <stdarg.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+/* This feature is available in gcc versions 2.5 and later and in clang.  */
+# if !((__GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || defined __clang__) && !__STRICT_ANSI__)
 #  define __attribute__(Spec) /* empty */
 # endif
-/* The __-protected variants of 'format' and 'printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+/* The __-protected variants of 'format' and 'printf' attributes are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later and in clang.  */
+# if !(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__)
 #  define __format__ format
 #  define __printf__ printf
 # endif
index a1f727871c38778092aa9cab784b266ec4cc56bb..d370f9e6040df8ff3bd276472f37d5efd939e213 100644 (file)
@@ -1,5 +1,5 @@
 /* Public API for GNU gettext PO files - contained in libgettextpo.
-   Copyright (C) 2003-2025 Free Software Foundation, Inc.
+   Copyright (C) 2003-2026 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -59,7 +59,7 @@ struct po_error_handler
      Must not return if STATUS is nonzero.  */
   void (*error) (int status, int errnum,
                  const char *format, ...)
-#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__
+#if (((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) || defined __clang__) && !__STRICT_ANSI__
   __attribute__ ((__format__ (__printf__, 3, 4)))
 #endif
   ;
@@ -72,7 +72,7 @@ struct po_error_handler
   void (*error_at_line) (int status, int errnum,
                          const char *filename, unsigned int lineno,
                          const char *format, ...)
-#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__
+#if (((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) || defined __clang__) && !__STRICT_ANSI__
   __attribute__ ((__format__ (__printf__, 5, 6)))
 #endif
   ;
index c262a292ba249e50d6318883fde514b1aba70dfa..ef8b2e6a0a5b0104e9a8d2975b93220481280921 100644 (file)
@@ -1,5 +1,5 @@
 /* Format strings.
-   Copyright (C) 2001-2025 Free Software Foundation, Inc.
+   Copyright (C) 2001-2026 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -56,7 +56,7 @@ enum
 
 /* This type of callback is responsible for showing an error.  */
 typedef void (*formatstring_error_logger_t) (void *data, const char *format, ...)
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 2, 3)))
 #endif
 ;
index 5b8c893727c37f9c30b40acda39e7ade6e6cef8a..31f542bacb31c14fcfe7ad68066edd687bf780f7 100644 (file)
@@ -1,5 +1,5 @@
 /* Error handling during reading of input files.
-   Copyright (C) 2023-2025 Free Software Foundation, Inc.
+   Copyright (C) 2023-2026 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -47,14 +47,14 @@ extern "C" {
 extern void if_error (int severity,
                       const char *filename, size_t lineno, size_t column,
                       bool multiline, const char *format, ...)
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 6, 7)))
 #endif
      ;
 extern void if_verror (int severity,
                        const char *filename, size_t lineno, size_t column,
                        bool multiline, const char *format, va_list args)
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 6, 0)))
 #endif
      ;
index 412a0f9650d8ad13dcd82acc60f6ee5f90d82da8..f569a095b0585e385247d8078e212fa6ca1c2e6c 100644 (file)
@@ -1,5 +1,5 @@
 /* Checking of messages in PO files.
-   Copyright (C) 1995-2025 Free Software Foundation, Inc.
+   Copyright (C) 1995-2026 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
 
    This program is free software: you can redistribute it and/or modify
@@ -490,7 +490,7 @@ struct formatstring_error_logger_locals
 };
 static void
 formatstring_error_logger (void *data, const char *format, ...)
-#if defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)
+#if (defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 2, 3)))
 #endif
 ;
index 1a6585feccc2db22834be02cd24054eb9ba6b424..894cb6c34c8212af5a2ee2f8305c3dd8d476986a 100644 (file)
@@ -1,5 +1,5 @@
 /* Merging a .po file with a .pot file.
-   Copyright (C) 1995-2025 Free Software Foundation, Inc.
+   Copyright (C) 1995-2026 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -283,7 +283,7 @@ definitions_destroy (definitions_ty *definitions)
    occurred at all.  */
 static void
 silent_error_logger (void *data, const char *format, ...)
-#if defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)
+#if (defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 2, 3)))
 #endif
 ;
index 58ac612f607dfe89f546fc1bcb252d682c76cb65..8aa0acb62839ab0f70fb3c5d1e53601b92612a91 100644 (file)
@@ -1,5 +1,5 @@
 /* Error handling during reading and writing of PO files.
-   Copyright (C) 2004-2025 Free Software Foundation, Inc.
+   Copyright (C) 2004-2026 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2004.
 
    This program is free software: you can redistribute it and/or modify
 #define _PO_ERROR_H
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+/* This feature is available in gcc versions 2.5 and later and in clang.  */
+# if !((__GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || defined __clang__) && !__STRICT_ANSI__)
 #  define __attribute__(Spec) /* empty */
 # endif
-/* The __-protected variants of 'format' and 'printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+/* The __-protected variants of 'format' and 'printf' attributes are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later and in clang.  */
+# if !(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__)
 #  define __format__ format
 #  define __printf__ printf
 # endif
@@ -45,7 +45,7 @@ extern "C" {
 extern LIBGETTEXTSRC_DLL_VARIABLE
        void (*po_error) (int status, int errnum,
                          const char *format, ...)
-#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
+#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) || defined __clang__
        __attribute__ ((__format__ (__printf__, 3, 4)))
 #endif
        ;
@@ -53,7 +53,7 @@ extern LIBGETTEXTSRC_DLL_VARIABLE
        void (*po_error_at_line) (int status, int errnum,
                                  const char *filename, unsigned int lineno,
                                  const char *format, ...)
-#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
+#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) || defined __clang__
        __attribute__ ((__format__ (__printf__, 5, 6)))
 #endif
        ;
index 96f5692b4a53d5c2c82f62fae4cefb80b04c1970..3b700c52378a7fd07dfe92da1390b1ad85786bac 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+   Copyright (C) 1995-2026 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
 #include "read-catalog-abstract.h"
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+/* This feature is available in gcc versions 2.5 and later and in clang.  */
+# if !((__GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || defined __clang__) && !__STRICT_ANSI__)
 #  define __attribute__(Spec) /* empty */
 # endif
-/* The __-protected variants of 'format' and 'printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+/* The __-protected variants of 'format' and 'printf' attributes are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later and in clang.  */
+# if !(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__)
 #  define __format__ format
 #  define __printf__ printf
 # endif
index 7c41f157600c1ed3e653a0d45c256f66842fad1b..abc8b3fbdce5d590f600fc9217dcf21f26041a36 100644 (file)
@@ -559,7 +559,7 @@ struct formatstring_error_logger_locals
 };
 static void
 formatstring_error_logger (void *data, const char *format, ...)
-#if defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)
+#if (defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2)) || defined __clang__
      __attribute__ ((__format__ (__printf__, 2, 3)))
 #endif
 ;
index dc78e7132aca2bb632c7ce1f0451fdfda471ee89..3215b7b6f98b2c916d48fd10fc9e6454f205dbc2 100644 (file)
@@ -1,5 +1,5 @@
 /* Abstract output stream data type.
-   Copyright (C) 2006, 2019 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2019-2026 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2006.
 
    This program is free software: you can redistribute it and/or modify
@@ -70,13 +70,13 @@ extern void ostream_write_str (ostream_t stream, const char *string);
    Returns the size of formatted output, or a negative value in case of an
    error.  */
 extern ptrdiff_t ostream_printf (ostream_t stream, const char *format, ...)
-#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
+#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3 || defined __clang__
   __attribute__ ((__format__ (__printf__, 2, 3)))
 #endif
   ;
 extern ptrdiff_t ostream_vprintf (ostream_t stream,
                                   const char *format, va_list args)
-#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
+#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3 || defined __clang__
   __attribute__ ((__format__ (__printf__, 2, 0)))
 #endif
   ;