Improve support for clang on native Windows.

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.
This commit is contained in:
Bruno Haible 2026-01-11 01:21:58 +01:00
parent 144474ff64
commit 68e2e2c2d1
11 changed files with 42 additions and 42 deletions

View 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
@ -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

View 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
@ -21,13 +21,13 @@
#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

View 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
;

View 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
;

View 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
;

View 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
;

View 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
;

View 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
@ -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
;

View 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>
@ -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

View 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
;

View 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
;