我想做这样的事情:
#define NEED3ARGS(a1,a2,a3) ( "[" #a1 " + " #a2 " + " #a3 "]" )
#define MULTIARG() ARG1, ARG2, ARG3
NEED3ARGS( MULTIARG() )
我希望它输出如下内容:
( "[" "ARG1" " + " "ARG2" " + " "ARG3" "]" )
但相反,我有:
$ cpp multiarg.c
# 1 "multiarg.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "multiarg.c"
multiarg.c:4:23: error: macro "NEED3ARGS" requires 3 arguments, but only 1 given
NEED3ARGS
有没有办法使用 ANSI-C/GNU GCC 和 C 预处理器来做我想做的事?
谢谢!