Why won't this compile and how can it be implemented so that it does?

后端 未结 6 826
挽巷
挽巷 2020-12-21 12:30

Here is some C++ code I\'m playing around with:

#include 
#include 

#define IN ,
#define FOREACH(x,y) for(unsigned int i=0;i&l         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-21 12:53

    #define IN ,
    #define XFOREACH(x,y) for(unsigned int i=0;i

    As previous posters have noted, the preprocessor does not expand macros in the arglist before it splits it into argument. However, as long as the macro doesn't use # or ##, it expands macros in the args before substituting them into the macro body, so an extra indirection does the trick

提交回复
热议问题