Macro as a parameter to another macro

后端 未结 2 1154
遇见更好的自我
遇见更好的自我 2021-01-13 22:15

I\'m trying to pass the parameters to macro SETBIT with another predefined macro like this:

#define SETBIT(ADDRESS,BIT,N) {(N) ? (ADDRESS &=         


        
2条回答
  •  梦谈多话
    2021-01-13 22:49

    Just for the sake of completeness, that same manual you are linking to also states:

    The number of arguments you give must match the number of parameters in the macro definition. When the macro is expanded, each use of a parameter in its body is replaced by the tokens of the corresponding argument.

    So ooga's example is a nice demonstration of how macro expansion works recursively, first the outer macro gets expanded, then the argument.

提交回复
热议问题