From 810841e1b944bb034ddef854e916e4bf4aab3b45 Mon Sep 17 00:00:00 2001
From: Thierry Bultel <thierry.bultel@iot.bzh>
Date: Thu, 24 May 2018 10:03:20 +0200
Subject: Added afb-helpers-utils.h

Added this file to some useful macros, the first one here is INT_STR_MAX that
permits to get rid of a warning with gcc >= 7.2.0

Change-Id: I768d216ab5494d346d5ee6e0df66f93410bfab57
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
---
 afb-helpers-utils.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 afb-helpers-utils.h

diff --git a/afb-helpers-utils.h b/afb-helpers-utils.h
new file mode 100644
index 0000000..d180f08
--- /dev/null
+++ b/afb-helpers-utils.h
@@ -0,0 +1,17 @@
+#ifndef AFB_HELPERS_UTILS_H
+#define AFB_HELPERS_UTILS_H
+
+#include <limits.h>
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+/* with gcc >= 7.2.0, this macro is useful when printing an int with snprintf:
+ *
+ * char[INT_STR_MAX]; // smaller value leads to a warning
+ * snprintf(targetS, sizeof (targetS), "%d", target);
+ * */
+
+#define INT_STR_MAX sizeof(xstr(INT_MAX))
+
+#endif /* AFB_HELPERS_UTILS_H */
-- 
cgit