From 8cb45e5e4cd751cd206a2bbea71e6efafcb23540 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 26 Apr 2012 08:51:19 +0000 Subject: [PATCH] Allow gcc to check for correct usage of the formatting string for the logging class. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4904 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/LogWriter.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h index 7f8b68d7..23e3069c 100644 --- a/common/rfb/LogWriter.h +++ b/common/rfb/LogWriter.h @@ -25,12 +25,18 @@ #include #include +#ifdef __GNUC__ +# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) +#else +# define __printf_attr(a, b) +#endif // __GNUC__ + // Each log writer instance has a unique textual name, // and is attached to a particular Log instance and // is assigned a particular log level. #define DEF_LOGFUNCTION(name, level) \ - inline void name(const char* fmt, ...) { \ + inline void name(const char* fmt, ...) __printf_attr(2, 3) { \ if (m_log && (level <= m_level)) { \ va_list ap; va_start(ap, fmt); \ m_log->write(level, m_name, fmt, ap);\ @@ -53,7 +59,7 @@ namespace rfb { void setLevel(int level); int getLevel(void) { return m_level; } - inline void write(int level, const char* format, ...) { + inline void write(int level, const char* format, ...) __printf_attr(3, 4) { if (m_log && (level <= m_level)) { va_list ap; va_start(ap, format); -- 2.39.5