How to generate a newline in a cpp macro?

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

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

7条回答
  •  生来不讨喜
    2020-12-03 10:03

    The C compiler is aware of white space, but it doesn't distinguish between spaces, tabs or new lines.

    If you mean how do I have a new line inside a string in a macro, then:

    #define SOME_STRING "Some string\n with a new line."
    

    will work.

提交回复
热议问题