]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
tuklib_mbstr_wrap: Add printf format attribute
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 4 Jan 2025 12:41:37 +0000 (14:41 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sat, 4 Jan 2025 15:37:46 +0000 (17:37 +0200)
It's supported by GCC 3.x already.

src/common/tuklib_common.h
src/common/tuklib_mbstr_wrap.h

index 9fd5da9026af5f2c255d7b6d792584b6f75556f9..d73f07255e4d1a3a7a7a332af007926f5a8e2e66 100644 (file)
 #      define TUKLIB_GNUC_REQ(major, minor) 0
 #endif
 
+#if defined(__GNUC__) || defined(__clang__)
+#      define tuklib_attr_format_printf(fmt_index, args_index) \
+               __attribute__((__format__(__printf__, fmt_index, args_index)))
+#else
+#      define tuklib_attr_format_printf(fmt_index, args_index)
+#endif
+
 // tuklib_attr_noreturn attribute is used to mark functions as non-returning.
 // We cannot use "noreturn" as the macro name because then C23 code that
 // uses [[noreturn]] would break as it would expand to [[ [[noreturn]] ]].
index e20ffdaff1f8bb8c18938fbed7cd46083fc2878c..4e2f297dabb4121edb03185505297ceea4f2fe17 100644 (file)
@@ -186,6 +186,7 @@ extern int tuklib_wraps(FILE *stream, const struct tuklib_wrap_opt *opt,
 ///             all strings have (hopefully) been printed.
 
 #define tuklib_wrapf TUKLIB_SYMBOL(tuklib_wrapf)
+tuklib_attr_format_printf(3, 4)
 extern int tuklib_wrapf(FILE *stream, const struct tuklib_wrap_opt *opt,
                const char *fmt, ...);
 ///<