1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
---|
2 | <html>
|
---|
3 | <!-- Copyright (C) 2022 Richard Stallman and Free Software Foundation, Inc.
|
---|
4 |
|
---|
5 | (The work of Trevis Rothwell and Nelson Beebe has been assigned or
|
---|
6 | licensed to the FSF.)
|
---|
7 |
|
---|
8 | Permission is granted to copy, distribute and/or modify this document
|
---|
9 | under the terms of the GNU Free Documentation License, Version 1.3 or
|
---|
10 | any later version published by the Free Software Foundation; with the
|
---|
11 | Invariant Sections being "GNU General Public License," with the
|
---|
12 | Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
---|
13 | Texts as in (a) below. A copy of the license is included in the
|
---|
14 | section entitled "GNU Free Documentation License."
|
---|
15 |
|
---|
16 | (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
---|
17 | modify this GNU manual. Buying copies from the FSF supports it in
|
---|
18 | developing GNU and promoting software freedom." -->
|
---|
19 | <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
|
---|
20 | <head>
|
---|
21 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
---|
22 | <title>Line Continuation (GNU C Language Manual)</title>
|
---|
23 |
|
---|
24 | <meta name="description" content="Line Continuation (GNU C Language Manual)">
|
---|
25 | <meta name="keywords" content="Line Continuation (GNU C Language Manual)">
|
---|
26 | <meta name="resource-type" content="document">
|
---|
27 | <meta name="distribution" content="global">
|
---|
28 | <meta name="Generator" content="makeinfo">
|
---|
29 | <link href="index.html" rel="start" title="Top">
|
---|
30 | <link href="Symbol-Index.html" rel="index" title="Symbol Index">
|
---|
31 | <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
---|
32 | <link href="Lexical-Syntax.html" rel="up" title="Lexical Syntax">
|
---|
33 | <link href="Arithmetic.html" rel="next" title="Arithmetic">
|
---|
34 | <link href="Operators_002fPunctuation.html" rel="prev" title="Operators/Punctuation">
|
---|
35 | <style type="text/css">
|
---|
36 | <!--
|
---|
37 | a.summary-letter {text-decoration: none}
|
---|
38 | blockquote.indentedblock {margin-right: 0em}
|
---|
39 | div.display {margin-left: 3.2em}
|
---|
40 | div.example {margin-left: 3.2em}
|
---|
41 | div.lisp {margin-left: 3.2em}
|
---|
42 | kbd {font-style: oblique}
|
---|
43 | pre.display {font-family: inherit}
|
---|
44 | pre.format {font-family: inherit}
|
---|
45 | pre.menu-comment {font-family: serif}
|
---|
46 | pre.menu-preformatted {font-family: serif}
|
---|
47 | span.nolinebreak {white-space: nowrap}
|
---|
48 | span.roman {font-family: initial; font-weight: normal}
|
---|
49 | span.sansserif {font-family: sans-serif; font-weight: normal}
|
---|
50 | ul.no-bullet {list-style: none}
|
---|
51 | -->
|
---|
52 | </style>
|
---|
53 |
|
---|
54 |
|
---|
55 | </head>
|
---|
56 |
|
---|
57 | <body lang="en">
|
---|
58 | <span id="Line-Continuation"></span><div class="header">
|
---|
59 | <p>
|
---|
60 | Previous: <a href="Operators_002fPunctuation.html" accesskey="p" rel="prev">Operators/Punctuation</a>, Up: <a href="Lexical-Syntax.html" accesskey="u" rel="up">Lexical Syntax</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
|
---|
61 | </div>
|
---|
62 | <hr>
|
---|
63 | <span id="Line-Continuation-1"></span><h3 class="section">5.7 Line Continuation</h3>
|
---|
64 | <span id="index-line-continuation"></span>
|
---|
65 | <span id="index-continuation-of-lines"></span>
|
---|
66 |
|
---|
67 | <p>The sequence of a backslash and a newline is ignored absolutely
|
---|
68 | anywhere in a C program. This makes it possible to split a single
|
---|
69 | source line into multiple lines in the source file. GNU C tolerates
|
---|
70 | and ignores other whitespace between the backslash and the newline.
|
---|
71 | In particular, it always ignores a CR (carriage return) character
|
---|
72 | there, in case some text editor decided to end the line with the CRLF
|
---|
73 | sequence.
|
---|
74 | </p>
|
---|
75 | <p>The main use of line continuation in C is for macro definitions that
|
---|
76 | would be inconveniently long for a single line (see <a href="Macros.html">Macros</a>).
|
---|
77 | </p>
|
---|
78 | <p>It is possible to continue a line comment onto another line with
|
---|
79 | backslash-newline. You can put backslash-newline in the middle of an
|
---|
80 | identifier, even a keyword, or an operator. You can even split
|
---|
81 | ‘<samp>/*</samp>’, ‘<samp>*/</samp>’, and ‘<samp>//</samp>’ onto multiple lines with
|
---|
82 | backslash-newline. Here’s an ugly example:
|
---|
83 | </p>
|
---|
84 | <div class="example">
|
---|
85 | <pre class="example">/\
|
---|
86 | *
|
---|
87 | */ fo\
|
---|
88 | o +\
|
---|
89 | = 1\
|
---|
90 | 0;
|
---|
91 | </pre></div>
|
---|
92 |
|
---|
93 | <p>That’s equivalent to ‘<samp>/* */ foo += 10;</samp>’.
|
---|
94 | </p>
|
---|
95 | <p>Don’t do those things in real programs, since they make code hard to
|
---|
96 | read.
|
---|
97 | </p>
|
---|
98 | <p><strong>Note:</strong> For the sake of using certain tools on the source code, it is
|
---|
99 | wise to end every source file with a newline character which is not
|
---|
100 | preceded by a backslash, so that it really ends the last line.
|
---|
101 | </p>
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | </body>
|
---|
106 | </html>
|
---|