C ++ preprocessor string wrapping

How to wrap a preprocessor directive string and ignore extra space?

Test code:

    #error Line0\
    Line 1

Result:

short_test.cpp(1): error: #error directive: Line0    Line 1
      #error Line0\
       ^

While I want to keep the indentation pattern in the test code, I don't want the gap between line0 and line1 to be obtained.

Is it possible?

The result I want:

short_test.cpp(1): error: #error directive: Line0Line 1
no space between Line0 and Line1

Test code i want

    #error Line0\
    (extra stuff?) Line 1  <-- keep the indent, ok to insert some extra stuff.
+4
source share
1 answer

You can't, sorry.

The preprocessor will do exactly what you give it, including any indentation.

+2
source

Source: https://habr.com/ru/post/1655862/


All Articles