aboutsummaryrefslogtreecommitdiff
path: root/libvpx/tools_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'libvpx/tools_common.h')
-rw-r--r--libvpx/tools_common.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/libvpx/tools_common.h b/libvpx/tools_common.h
index 4e8851fc1..b9cfb9cc8 100644
--- a/libvpx/tools_common.h
+++ b/libvpx/tools_common.h
@@ -116,12 +116,24 @@ extern "C" {
#define VPX_NO_RETURN
#endif
+// Tells the compiler to perform `printf` format string checking if the
+// compiler supports it; see the 'format' attribute in
+// <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html>.
+#define VPX_TOOLS_FORMAT_PRINTF(string_index, first_to_check)
+#if defined(__has_attribute)
+#if __has_attribute(format)
+#undef VPX_TOOLS_FORMAT_PRINTF
+#define VPX_TOOLS_FORMAT_PRINTF(string_index, first_to_check) \
+ __attribute__((__format__(__printf__, string_index, first_to_check)))
+#endif
+#endif
+
/* Sets a stdio stream into binary mode */
FILE *set_binary_mode(FILE *stream);
-VPX_NO_RETURN void die(const char *fmt, ...);
-VPX_NO_RETURN void fatal(const char *fmt, ...);
-void warn(const char *fmt, ...);
+VPX_NO_RETURN void die(const char *fmt, ...) VPX_TOOLS_FORMAT_PRINTF(1, 2);
+VPX_NO_RETURN void fatal(const char *fmt, ...) VPX_TOOLS_FORMAT_PRINTF(1, 2);
+void warn(const char *fmt, ...) VPX_TOOLS_FORMAT_PRINTF(1, 2);
VPX_NO_RETURN void die_codec(vpx_codec_ctx_t *ctx, const char *s);