|
From: | Anthony Liguori |
Subject: | Re: [Qemu-devel] [PATCH 2/7] add strify() macros. |
Date: | Mon, 13 Jul 2009 08:54:56 -0500 |
User-agent: | Thunderbird 2.0.0.21 (X11/20090320) |
Gerd Hoffmann wrote:
Signed-off-by: Gerd Hoffmann <address@hidden> --- osdep.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/osdep.h b/osdep.h index ffbf221..ac660c8 100644 --- a/osdep.h +++ b/osdep.h @@ -27,6 +27,11 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif+#ifndef strify+#define strify_i(a) # a +#define strify(a) strify_i(a) +#endif +
Could get even fancier with something like: #define strify_i(a) # a #define strify(a) strify_i(a) #define to_prop(a) __builtin_choose_expr( \ __builtin_types_compatible_p(typeof(a), const char []), \ (a), \ __builtin_choose_expr( \ __builtin_types_compatible_p(typeof(a), int) || \ __builtin_types_compatible_p(typeof(a), double), \ strify(a), \ (int *)0)) It should be possible to use to_prop() for any property initializer. Regards, Anthony Liguori
[Prev in Thread] | Current Thread | [Next in Thread] |