Stringify support commas v2
RFC PATCH 1/1 Stringify support commas v2
#define MYDEF a, b, c
__stringify(MYDEF) should be replaced by "a, b, c", but compilation fails because the __stringify macro expects only one argument. Fix it by using variable macro arguments in __stringify and __stringify_1.
Needed in my current NMI safe iret paravirt support work so I can expand a macro containing assembly code into a string.
Since some architectures still use -traditional, which does not support macros with variable arguments, keep the old stringify around. Test with __STDC__ to see if -traditional is used.
Signed-off-by Mathieu Desnoyers <[email protected]>
CC Sam Ravnborg <[email protected]>
--- include/linux/stringify.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/stringify.h +5 -0
@@ -6,7 +6,12 @@* converts to "bar". */ +#ifdef __STDC__ +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) +#else /* Support gcc -traditional, without commas. */ #define __stringify_1 (x) #x#define __stringify (x) __stringify_1(x) +#endif #endif /* !__LINUX_STRINGIFY_H */
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68