aboutsummaryrefslogtreecommitdiffstats
path: root/include/rin
diff options
context:
space:
mode:
Diffstat (limited to 'include/rin')
-rw-r--r--include/rin/definitions.h10
-rw-r--r--include/rin/diagnostic.h9
2 files changed, 15 insertions, 4 deletions
diff --git a/include/rin/definitions.h b/include/rin/definitions.h
index 19dde14..b8b6da3 100644
--- a/include/rin/definitions.h
+++ b/include/rin/definitions.h
@@ -26,6 +26,12 @@
/* weak symbols */
# define WEAK_SYM __attribute__((weak))
+
+/* allow the compiler to check varargs */
+/*
+# define FORMAT_STRING(a, b) __attribute__((format (printf, a, b)))
+*/
+
/* optimizing likely / unlikely branches */
# define likely(a) (__builtin_expect(!!(a), 1))
# define unlikely(a) (__builtin_expect((a), 0))
@@ -35,6 +41,9 @@
/* weak symbols */
# define WEAK_SYM __declspec(selectany)
+
+# define FORMAT_STRING(a, b)
+
/* optimizing likely / unlikely branches */
# define likely(a) (a)
# define unlikely(a) (a)
@@ -42,6 +51,7 @@
/* the rest – NOOP */
#else
# define WEAK_SYM
+# define FORMAT_STRING(a, b)
# define likely(a) (a)
# define unlikely(a) (a)
#endif
diff --git a/include/rin/diagnostic.h b/include/rin/diagnostic.h
index de925cc..128e059 100644
--- a/include/rin/diagnostic.h
+++ b/include/rin/diagnostic.h
@@ -21,6 +21,7 @@
#ifndef LIBRIN_DIAGNOSTIC_INCLUDED
#define LIBRIN_DIAGNOSTIC_INCLUDED
+#include "rin/definitions.h"
#include <stdio.h>
#define RIN_DIAG_SET 1
@@ -42,9 +43,9 @@ enum rin_diag_outstream {
int rin_diag_flags(int flag, int action);
int rin_diag_set_outstream(enum rin_diag_outstream channel, FILE *stream);
-void rin_err(const char *format, ...);
-void rin_fixme(const char *format, ...);
-void rin_warn(const char *format, ...);
-void rin_info(const char *format, ...);
+void rin_err(const char *format, ...) FORMAT_STRING(1, 2);
+void rin_fixme(const char *format, ...) FORMAT_STRING(1, 2);
+void rin_warn(const char *format, ...) FORMAT_STRING(1, 2);
+void rin_info(const char *format, ...) FORMAT_STRING(1, 2);
#endif /* LIBRIN_DIAGNOSTIC_INCLUDED */