Macro function with several lines for the parameter?

后端 未结 6 1003
悲哀的现实
悲哀的现实 2021-01-07 23:09

In C++, I need to defined a macro. That macro would take as parameter a \"block\" of code.

Can we safely use several lines of code as parameter of a macro fu

6条回答
  •  萌比男神i
    2021-01-08 00:12

    A macro with multiple lines for parameter is fine also in case of multiple arguments, it even allows "commas" inside, but I strongly descourage using "commas" beause if it is not ambiguos to a machine it is certainly ambiguos to humans:

    #include 
    using namespace std;
    
    #define MACRO2FUN( X, Y) x; y;
    void function(int a, int b, int c){
        std::cout<

提交回复
热议问题