C preprocessor Macro defining Macro

后端 未结 6 1203
耶瑟儿~
耶瑟儿~ 2020-12-29 01:49

Can you do something like this with a macro in C?

#define SUPERMACRO(X,Y) #define X Y

then

SUPERMACRO(A,B) expands to #define A B
<         


        
6条回答
  •  庸人自扰
    2020-12-29 02:06

    Macros can't expand into preprocessing directives. From C99 6.10.3.4/3 "Rescanning and further replacement":

    The resulting completely macro-replaced preprocessing token sequence is not processed as a preprocessing directive even if it resembles one,

提交回复
热议问题