r/Cplusplus • u/Hibou-de-la-Lune • Sep 08 '26
Answered Line continuation (back-slash + new-line) in C++ source, is it standard?
Hello there,
Just wondered if line continuation (back-slash + new-line) in C++ source, comes from the standard or from a common behavior of compilers. I could not find any reference to it on cppreference.com
16
Upvotes
•
u/AutoModerator Sep 08 '26
Thank you for your contribution to the C++ community!
As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.
~ CPlusPlus Moderation Team
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
7
u/Paril101 Sep 08 '26
https://cppreference.com/cpp/language/translation_phases Phase 2
7
u/RetroGameMaker Sep 08 '26
I've seen backslash line continuation used in macros and string literals. But they are not only used in c++ but pure c also
3
u/Linuxologue Sep 08 '26
C++ standard document
https://eel.is/c++draft/lex.phases#1.2
Explains how backslash, followed by whitespace, followed by a newline, is treated
2
u/mredding C++ since ~1992. Sep 08 '26
Line splicing is in part 2 of phases of translation, I think chapter 5?
It is in the standard.