Macros and multi-line comments

c++, macros

Solution

You can't do it for the following reasoning. Let's assume it is possible.

So you created a macro that replaces itself with `/*`, and another for `*/`. What happens then? First, the comments are removed from the code. After that, the preprocessor replaces your macros with the comments. After that, the compiler will choke: it doesn't know what to do with `/*` and `*/` because it simply never faces such things: the comments are always delete before the compilation, so it doesn't even know what a "comment" is. It will probably think it's a division followed by multiplication.

So our assumption is wrong and you can't do it.

Problem

I need to have multi-line comments within a group of macros so that one of the macros initiates a comment block and another concludes it, like this: ``` #define C_BEGIN /* #define C_END */ ... other macros ``` But sure enough, this approach doesn't work.

Original source