Tell me, is it possible to do comments in C / C ++ inside macros?

And if so, then:

1) How to make comments in a trivial multi-line macro:

#define BEGIN_MACRO\ for (...;...;...)\ {\ if (...)\ { while (...)\ { 

2) How to make comments in multi-line macro functions?

    2 answers 2

    Comments in the source code are replaced with spaces at the earliest stages of translation: after the merging of source lines by characters \ at the ends of lines, but even before some “substantial” work of the preprocessor begins. The splitting into lines formed after processing \ is preserved.

    That is, you can insert comments into the macro, but for this you should use the comments in the style of /* ... */ and do not forget to put \ after such a comment so that the macro does not "explode"

     #define MAX(a, b) \ /* Maximum */ \ ((a) > (b) ? (a) : (b)) 

    A single line comment // in macro will be used only in its last line, because such a comment with the \ character at the end will actually become multi-line and “swallow” the next line of macro.

       #define BEGIN_MACRO\ /* Супер-пупер макрос */ \ for (...;...;...)\ {\ if (...)\ { while (...)\ { 

      Well, in the function - exactly the same ...

      • And if the comments are single-line ...?) - user294535
      • one
        I was tormented here with one-line comments, well, I’m bread ...) - user294535
      • Doxigen style is also suitable in macros. - NewView
      • @AnT Ah, yes, of course you are right. Just forgot ... - Harry
      • @NewView From the point of view of language, this is an ordinary /* */ , with the symbol added after the asterisk. - HolyBlackCat