From: Bruno Haible Date: Sun, 11 Jan 2026 00:21:58 +0000 (+0100) Subject: Improve support for clang on native Windows. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68e2e2c2d11850ba14a05964b249fc941b0b0ada;p=thirdparty%2Fgettext.git Improve support for clang on native Windows. Reported by Kirill Makurin in . * 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. --- diff --git a/gettext-runtime/libasprintf/autosprintf.in.h b/gettext-runtime/libasprintf/autosprintf.in.h index de048dfa9..a73dc0b3b 100644 --- a/gettext-runtime/libasprintf/autosprintf.in.h +++ b/gettext-runtime/libasprintf/autosprintf.in.h @@ -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 @@ -17,13 +17,13 @@ #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 diff --git a/gettext-runtime/libasprintf/vasprintf.h b/gettext-runtime/libasprintf/vasprintf.h index 2b65c7217..1e0290c12 100644 --- a/gettext-runtime/libasprintf/vasprintf.h +++ b/gettext-runtime/libasprintf/vasprintf.h @@ -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 @@ -21,13 +21,13 @@ #include #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 diff --git a/gettext-tools/libgettextpo/gettext-po.in.h b/gettext-tools/libgettextpo/gettext-po.in.h index a1f727871..d370f9e60 100644 --- a/gettext-tools/libgettextpo/gettext-po.in.h +++ b/gettext-tools/libgettextpo/gettext-po.in.h @@ -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 , 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 ; diff --git a/gettext-tools/src/format.h b/gettext-tools/src/format.h index c262a292b..ef8b2e6a0 100644 --- a/gettext-tools/src/format.h +++ b/gettext-tools/src/format.h @@ -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 , 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 ; diff --git a/gettext-tools/src/if-error.h b/gettext-tools/src/if-error.h index 5b8c89372..31f542bac 100644 --- a/gettext-tools/src/if-error.h +++ b/gettext-tools/src/if-error.h @@ -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 ; diff --git a/gettext-tools/src/msgl-check.c b/gettext-tools/src/msgl-check.c index 412a0f965..f569a095b 100644 --- a/gettext-tools/src/msgl-check.c +++ b/gettext-tools/src/msgl-check.c @@ -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 , 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 ; diff --git a/gettext-tools/src/msgl-merge.c b/gettext-tools/src/msgl-merge.c index 1a6585fec..894cb6c34 100644 --- a/gettext-tools/src/msgl-merge.c +++ b/gettext-tools/src/msgl-merge.c @@ -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 ; diff --git a/gettext-tools/src/po-error.h b/gettext-tools/src/po-error.h index 58ac612f6..8aa0acb62 100644 --- a/gettext-tools/src/po-error.h +++ b/gettext-tools/src/po-error.h @@ -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 , 2004. This program is free software: you can redistribute it and/or modify @@ -19,13 +19,13 @@ #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 ; diff --git a/gettext-tools/src/read-po-lex.h b/gettext-tools/src/read-po-lex.h index 96f5692b4..3b700c523 100644 --- a/gettext-tools/src/read-po-lex.h +++ b/gettext-tools/src/read-po-lex.h @@ -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 @@ -28,13 +28,13 @@ #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 diff --git a/gettext-tools/src/xg-check.c b/gettext-tools/src/xg-check.c index 7c41f1576..abc8b3fbd 100644 --- a/gettext-tools/src/xg-check.c +++ b/gettext-tools/src/xg-check.c @@ -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 ; diff --git a/libtextstyle/gnulib-local/lib/ostream.oo.h b/libtextstyle/gnulib-local/lib/ostream.oo.h index dc78e7132..3215b7b6f 100644 --- a/libtextstyle/gnulib-local/lib/ostream.oo.h +++ b/libtextstyle/gnulib-local/lib/ostream.oo.h @@ -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 , 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 ;