[binutils-gdb] libctf: use __attribute__((__gnu_printf__)) where appropriate
Nick Alcock
nix@sourceware.org
Wed Jun 4 11:53:33 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f86f9fd85999c7a483855793b3efe85da1d6eb74
commit f86f9fd85999c7a483855793b3efe85da1d6eb74
Author: Nick Alcock <nick.alcock@oracle.com>
Date: Tue Jun 3 13:39:33 2025 +0100
libctf: use __attribute__((__gnu_printf__)) where appropriate
We don't use any GNU-specific printf args, but this prevents warnings about
%z, observed on MinGW even though every libc anyone is likely to use there
supports %z perfectly well, and we're not stopping using it just because
MinGW complains. Doing this means we stand more chance of seeing *actual*
problems on such platforms without them being drowned in noise.
We turn this off on clang, which doesn't support __gnu_printf__.
Suggested by Eli Zaretskii.
libctf/
PR libctf/31863
* ctf-impl.h (_libctf_printflike_): Use __gnu_printf__.
Diff:
---
libctf/ctf-impl.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 2691a689d31..3217f921254 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -66,8 +66,13 @@ extern "C"
macros glibc may introduce, which have names of the pattern
__attribute_blah__. */
+#if defined (__clang__)
#define _libctf_printflike_(string_index,first_to_check) \
__attribute__ ((__format__ (__printf__, (string_index), (first_to_check))))
+#else
+#define _libctf_printflike_(string_index,first_to_check) \
+ __attribute__ ((__format__ (__gnu_printf__, (string_index), (first_to_check))))
+#endif
#define _libctf_unlikely_(x) __builtin_expect ((x), 0)
#define _libctf_unused_ __attribute__ ((__unused__))
#define _libctf_malloc_ __attribute__((__malloc__))
More information about the Binutils-cvs
mailing list