From a6bf8cea4bebab12ff3c279a798870775a7c7abf Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 26 Aug 2026 21:08:14 +0300 Subject: add printf attribute --- include/conts/conts.h | 10 ++++++++++ include/conts/sp.h | 1 + 2 files changed, 11 insertions(+) (limited to 'include') diff --git a/include/conts/conts.h b/include/conts/conts.h index 7f30873..a49a00c 100644 --- a/include/conts/conts.h +++ b/include/conts/conts.h @@ -4,6 +4,16 @@ #define CONTS_JOIN2(a, b) a##_##b #define CONTS_JOIN(a, b) CONTS_JOIN2(a, b) +#if !defined(__has_attribute) +#define __has_attribute(x) 0 +#endif + +#if __has_attribute(format) +#define CONTS_FMT(func, x, y) __attribute__ ((format(func, x, y))) +#else +#define CONTS_FMT(func, x, y) +#endif + #define CONTAINER_OF(ptr, type, member) \ (type *)((char *)(ptr) - offsetof(type, member)) diff --git a/include/conts/sp.h b/include/conts/sp.h index 73fcdda..2f88293 100644 --- a/include/conts/sp.h +++ b/include/conts/sp.h @@ -201,6 +201,7 @@ static inline int SP(append_vfmt)(struct SP_STRUCT *s, const char *fmt, va_list return 0; } +CONTS_FMT(__printf__, 2, 3) static inline int SP(append_fmt)(struct SP_STRUCT *s, const char *fmt, ...) { int r = 0; -- cgit v1.3