Browse Source

enable format string diagnostics for blog and bcrash on gcc and clang

Palana 12 years ago
parent
commit
f263d585bf
1 changed files with 10 additions and 0 deletions
  1. 10 0
      libobs/util/base.h

+ 10 - 0
libobs/util/base.h

@@ -47,9 +47,19 @@ EXPORT void base_set_log_handler(
 		void (*handler)(enum log_type, const char *, va_list));
 EXPORT void base_set_crash_handler(void (*handler)(const char *, va_list));
 
+#ifndef _MSC_VER
+#define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
+#else
+#define PRINTFATTR(f, a)
+#endif
+
+PRINTFATTR(2, 3)
 EXPORT void blog(enum log_type type, const char *format, ...);
+PRINTFATTR(1, 2)
 EXPORT void bcrash(const char *format, ...);
 
+#undef PRINTFATTR
+
 #ifdef __cplusplus
 }
 #endif