Browse Source

Tag the Exception constructor as a printf function

This allows the compiler to analyse the format strings and
arguments for correctness.
tags/v1.4.90
Pierre Ossman 9 years ago
parent
commit
5b3c5f49b1
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      common/rdr/Exception.h

+ 7
- 1
common/rdr/Exception.h View File

@@ -21,12 +21,18 @@
#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, ...);
Exception(const char *format = 0, ...) __printf_attr(2, 3);
virtual ~Exception() {}
virtual const char* str() const { return str_; }
};

Loading…
Cancel
Save