How to break a macro function across several lines (multiline macro) in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

#define EVEN_OR_ODD(num)         \
        if (num & 1)             \
            std::cout << "odd";  \
        else                     \
            std::cout << "even";

int main() {
 
    int a = 3;
 
    EVEN_OR_ODD(a);
}



/*
run:

odd

*/

 



answered Dec 3, 2022 by avibootz
...