C preprocessor Macro defining Macro

后端 未结 6 1174
耶瑟儿~
耶瑟儿~ 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 01:53

    No. The order of operations is such that all preprocessor directives are recognized before any macro expansion is done; thus, if a macro expands into something that looks like a preprocessor directive, it won't be recognized as such, but will rather be interpreted as (erroneous) C source text.

提交回复
热议问题