summaryrefslogtreecommitdiffstats
path: root/common/rfb/LogWriter.h
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2012-04-26 08:51:19 +0000
committerPierre Ossman <ossman@cendio.se>2012-04-26 08:51:19 +0000
commit8cb45e5e4cd751cd206a2bbea71e6efafcb23540 (patch)
tree061882a1e92bb4a1e6691b7d9605e70c51929708 /common/rfb/LogWriter.h
parente0df4c38a477a6b3fbcd2feea074ff5912352981 (diff)
downloadtigervnc-8cb45e5e4cd751cd206a2bbea71e6efafcb23540.tar.gz
tigervnc-8cb45e5e4cd751cd206a2bbea71e6efafcb23540.zip
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
Diffstat (limited to 'common/rfb/LogWriter.h')
-rw-r--r--common/rfb/LogWriter.h10
1 files 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 <rfb/Logger.h>
#include <rfb/Configuration.h>
+#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);