From: Thierry Bultel Date: Thu, 24 May 2018 08:03:20 +0000 (+0200) Subject: Added afb-helpers-utils.h X-Git-Tag: 6.99.3~23 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=810841e1b944bb034ddef854e916e4bf4aab3b45;p=src%2Flibafb-helpers.git 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 --- 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 + +#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 */