diff options
author | 2017-06-19 13:51:44 +0200 | |
---|---|---|
committer | 2017-08-08 17:24:00 +0200 | |
commit | 7c36569cc56a5d82bfe2d501ced76ff3a0a3af7b (patch) | |
tree | 071ee809f79a2a90a3099ad5ed7d6194aebe01ff /src | |
parent | c78a62c85c55e5bd8683792dbf86b6188349d921 (diff) |
util: add printf format check attributes
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/util.h | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -5,14 +5,21 @@ extern "C" { #endif -void lognotice(char const *fmt, ...); -void logerror(char const *fmt, ...); -void fatal(char const *fmt, ...); +#ifdef __GNUC__ +#define ATTR_FORMAT(stringindex, firsttocheck) __attribute__((format(printf, stringindex, firsttocheck))) +#else +#define ATTR_FORMAT(stringindex, firsttocheck) +#endif + +void lognotice(char const *fmt, ...) ATTR_FORMAT(1,2); +void logerror(char const *fmt, ...) ATTR_FORMAT(1,2); +void fatal(char const *fmt, ...) ATTR_FORMAT(1,2); #ifdef DEBUG_OUTPUT -void logdebug(char const *fmt, ...); +void logdebug(char const *fmt, ...) ATTR_FORMAT(1,2); #else -inline void logdebug(char const *fmt, ...) {} +static inline void logdebug(char const * fmt, ...) ATTR_FORMAT(1,2); +static inline void logdebug(char const * fmt, ...) {} #endif #ifdef __cplusplus |