These are supported by gcc and clang, and I don't think MSVC works well with our code anyway, so let's keep things simple and use these directly.pull/1574/head
@@ -21,18 +21,13 @@ | |||
#ifndef __RDR_EXCEPTION_H__ | |||
#define __RDR_EXCEPTION_H__ | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
namespace rdr { | |||
struct Exception { | |||
enum { len = 256 }; | |||
char str_[len]; | |||
Exception(const char *format = 0, ...) __printf_attr(2, 3); | |||
Exception(const char *format = 0, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
virtual ~Exception() {} | |||
virtual const char* str() const { return str_; } | |||
}; |
@@ -25,22 +25,20 @@ | |||
#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 v##name(const char* fmt, va_list ap) __printf_attr(2, 0) { \ | |||
inline void v##name(const char* fmt, va_list ap) \ | |||
__attribute__((__format__ (__printf__, 2, 0))) \ | |||
{ \ | |||
if (m_log && (level <= m_level)) \ | |||
m_log->write(level, m_name, fmt, ap); \ | |||
} \ | |||
inline void name(const char* fmt, ...) __printf_attr(2, 3) { \ | |||
inline void name(const char* fmt, ...) \ | |||
__attribute__((__format__ (__printf__, 2, 3))) \ | |||
{ \ | |||
if (m_log && (level <= m_level)) { \ | |||
va_list ap; va_start(ap, fmt); \ | |||
m_log->write(level, m_name, fmt, ap);\ | |||
@@ -63,7 +61,9 @@ namespace rfb { | |||
void setLevel(int level); | |||
int getLevel(void) { return m_level; } | |||
inline void write(int level, const char* format, ...) __printf_attr(3, 4) { | |||
inline void write(int level, const char* format, ...) | |||
__attribute__((__format__ (__printf__, 3, 4))) | |||
{ | |||
if (m_log && (level <= m_level)) { | |||
va_list ap; | |||
va_start(ap, format); |
@@ -28,12 +28,6 @@ | |||
// and is attached to a particular Logger instance and | |||
// is assigned a particular log level. | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
namespace rfb { | |||
class Logger { | |||
@@ -51,7 +45,8 @@ namespace rfb { | |||
// -=- Write data to a log | |||
virtual void write(int level, const char *logname, const char *text) = 0; | |||
void write(int level, const char *logname, const char* format, va_list ap) __printf_attr(4, 0); | |||
void write(int level, const char *logname, const char* format, va_list ap) | |||
__attribute__((__format__ (__printf__, 4, 0))); | |||
// -=- Register a logger | |||
@@ -222,7 +222,8 @@ namespace rfb { | |||
// throwConnFailedException() prints a message to the log, sends a conn | |||
// failed message to the client (if possible) and throws a | |||
// ConnFailedException. | |||
void throwConnFailedException(const char* format, ...) __printf_attr(2, 3); | |||
void throwConnFailedException(const char* format, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
void setState(stateEnum s) { state_ = s; } | |||
@@ -29,12 +29,6 @@ | |||
struct timeval; | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
namespace rfb { | |||
// -=- Class to handle cleanup of arrays of characters | |||
@@ -49,7 +43,8 @@ namespace rfb { | |||
~CharArray() { | |||
delete [] buf; | |||
} | |||
void format(const char *fmt, ...) __printf_attr(2, 3); | |||
void format(const char *fmt, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
// Get the buffer pointer & clear it (i.e. caller takes ownership) | |||
char* takeBuf() {char* tmp = buf; buf = 0; return tmp;} | |||
void replaceBuf(char* b) {delete [] buf; buf = b;} |
@@ -26,16 +26,14 @@ extern "C" { | |||
void vncInitRFB(void); | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
void vncLogError(const char *name, const char *format, ...) __printf_attr(2, 3); | |||
void vncLogStatus(const char *name, const char *format, ...) __printf_attr(2, 3); | |||
void vncLogInfo(const char *name, const char *format, ...) __printf_attr(2, 3); | |||
void vncLogDebug(const char *name, const char *format, ...) __printf_attr(2, 3); | |||
void vncLogError(const char *name, const char *format, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
void vncLogStatus(const char *name, const char *format, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
void vncLogInfo(const char *name, const char *format, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
void vncLogDebug(const char *name, const char *format, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
int vncSetParam(const char *name, const char *value); | |||
int vncSetParamSimple(const char *nameAndValue); |
@@ -24,18 +24,12 @@ | |||
extern "C" { | |||
#endif | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
# define __noreturn_attr __attribute__((noreturn)) | |||
#else | |||
# define __printf_attr(a, b) | |||
# define __noreturn_attr | |||
#endif // __GNUC__ | |||
const char *vncGetDisplay(void); | |||
unsigned long vncGetServerGeneration(void); | |||
void vncFatalError(const char *format, ...) __printf_attr(1, 2) __noreturn_attr; | |||
void vncFatalError(const char *format, ...) | |||
__attribute__((__format__ (__printf__, 1, 2))) | |||
__attribute__((noreturn)); | |||
int vncGetScreenCount(void); | |||
@@ -37,12 +37,6 @@ class Viewport; | |||
class Fl_Scrollbar; | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
class DesktopWindow : public Fl_Window { | |||
public: | |||
@@ -89,7 +83,8 @@ public: | |||
private: | |||
static void menuOverlay(void *data); | |||
void setOverlay(const char *text, ...) __printf_attr(2, 3); | |||
void setOverlay(const char *text, ...) | |||
__attribute__((__format__ (__printf__, 2, 3))); | |||
static void updateOverlay(void *data); | |||
static int fltkDispatch(int event, Fl_Window *win); |
@@ -21,18 +21,14 @@ | |||
#define VNCSERVERNAMELEN 256 | |||
#ifdef __GNUC__ | |||
# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) | |||
#else | |||
# define __printf_attr(a, b) | |||
#endif // __GNUC__ | |||
namespace rdr { | |||
struct Exception; | |||
}; | |||
void abort_vncviewer(const char *error, ...) __printf_attr(1, 2); | |||
void abort_connection(const char *error, ...) __printf_attr(1, 2); | |||
void abort_vncviewer(const char *error, ...) | |||
__attribute__((__format__ (__printf__, 1, 2))); | |||
void abort_connection(const char *error, ...) | |||
__attribute__((__format__ (__printf__, 1, 2))); | |||
void abort_connection_with_unexpected_error(const rdr::Exception &); | |||
void disconnect(); |