aboutsummaryrefslogtreecommitdiffstats
path: root/afb-helpers-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'afb-helpers-utils.h')
-rw-r--r--afb-helpers-utils.h17
1 files changed, 17 insertions, 0 deletions
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 */