C - 括号链到单个宏的宏

时间:2016-01-25 09:10:55

标签: c macros

正如主题所说,我正在尝试实现这样的语法(“宏魔术”): 产生宏的MAKE(123)(456),如'RESULT(123,456)'

// MAKE(123)(456)

#define COMMA ,
#define RESULT(A,B) ((A)+(B)) // Just for example. In fact, I want to concat arguments of two or more macros

#define LP (
#define RP )

#define MAKE(A) __MK1(A) __MK2

#define __MK1(A) RESULT LP A COMMA // I'm tried many combinationations.
#define __MK2(A) A RP
// RESULT(123, 456);

有可能做这样的事吗?

谢谢!

0 个答案:

没有答案