How to generate a newline in a cpp macro?

后端 未结 7 1136
北恋
北恋 2020-12-03 09:29

How do I write a cpp macro which expands to include newlines?

7条回答
  •  一向
    一向 (楼主)
    2020-12-03 10:18

    It is not possible. It would only be relevant if you were looking at listing files or pre-processor output.

    A common technique in writing macros so that they are easier to read is to use the \ character to continue the macro onto a following line.

    I (believe I) have seen compilers that include new lines in the expanded macros in listing output - for your benefit. This is only of use to us poor humans reading the expanded macros to try to understand what we really asked the compiler to do. it makes no difference to the compiler.

    The C & C++ languages treat all whitespace outside of strings in the same way. Just as a separator.

提交回复
热议问题