From f494c2d617a113009fc2e86ccdcad6e521800b82 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Thu, 5 Apr 2012 16:35:46 +0300 Subject: [PATCH] base: CONCAT macros for token merge --- usual/base.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/usual/base.h b/usual/base.h index 8fa652d..1941ef1 100644 --- a/usual/base.h +++ b/usual/base.h @@ -90,6 +90,22 @@ #define FLEX_ARRAY 1 #endif +/** Make string token from C expression */ +#define STR(x) _STR_(x) +#define _STR_(x) #x + +/** Make single C token from 2 separate tokens */ +#define CONCAT(a, b) _CONCAT_(a, b) +#define _CONCAT_(a, b) a ## b + +/** Make single C token from 3 separate tokens */ +#define CONCAT3(a, b, c) _CONCAT3_(a, b, c) +#define _CONCAT3_(a, b, c) a ## b ## c + +/** Make single C token from 4 separate tokens */ +#define CONCAT4(a, b, c, d) _CONCAT4_(a, b, c, d) +#define _CONCAT4_(a, b, c, d) a ## b ## c ## d + /** * @name Compiler attributes. */ @@ -185,9 +201,5 @@ static inline void *zmalloc(size_t len) int posix_memalign(void **ptr_p, size_t align, size_t len); #endif -/** cpp expr -> string */ -#define STR(x) _STR_(x) -#define _STR_(x) #x - #endif -- 2.39.5