[PATCH v4 13/22] util.h: Add concat() macro

From: Herve Codina

Date: Thu Nov 26 2026 - 06:29:51 EST


util.h defines the stringify() macro, which forces parameter expansion.

In the same way, define the concat() macro allowing the concatenation of
parameters forcing their expansion before the concatenation.

This allows the following:
--- 8< ---
#define bar 2
#define baz 3

#define foo concat(bar, baz) /* foo is set to 23 */
#define other concat(test,baz) /* other is set to test3 */
--- 8< ---

Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
---
util.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/util.h b/util.h
index 3e2ebaab..50014325 100644
--- a/util.h
+++ b/util.h
@@ -32,6 +32,9 @@
#define stringify(s) stringify_(s)
#define stringify_(s) #s

+#define concat(a, b) concat_(a, b)
+#define concat_(a, b) a ## b
+
static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
{
va_list ap;
--
2.56.1