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>include Syntax (GNU C Language Manual)</title>
|
---|
23 |
|
---|
24 | <meta name="description" content="include Syntax (GNU C Language Manual)">
|
---|
25 | <meta name="keywords" content="include Syntax (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="Header-Files.html" rel="up" title="Header Files">
|
---|
33 | <link href="include-Operation.html" rel="next" title="include Operation">
|
---|
34 | <link href="Header-Files.html" rel="prev" title="Header Files">
|
---|
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="include-Syntax"></span><div class="header">
|
---|
59 | <p>
|
---|
60 | Next: <a href="include-Operation.html" accesskey="n" rel="next">include Operation</a>, Up: <a href="Header-Files.html" accesskey="u" rel="up">Header Files</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="g_t_0023include-Syntax"></span><h4 class="subsection">26.4.1 <code>#include</code> Syntax</h4>
|
---|
64 |
|
---|
65 | <span id="index-_0023include"></span>
|
---|
66 | <p>You can specify inclusion of user and system header files with the
|
---|
67 | preprocessing directive <code>#include</code>. It has two variants:
|
---|
68 | </p>
|
---|
69 | <dl compact="compact">
|
---|
70 | <dt><code>#include <<var>file</var>></code></dt>
|
---|
71 | <dd><p>This variant is used for system header files. It searches for a file
|
---|
72 | named <var>file</var> in a standard list of system directories. You can
|
---|
73 | prepend directories to this list with the <samp>-I</samp> option
|
---|
74 | (see <a href="https://gcc.gnu.org/onlinedocs/gcc/Invocation.html#Invocation">Invoking GCC</a> in <cite>Using the GNU
|
---|
75 | Compiler Collection</cite>).
|
---|
76 | </p>
|
---|
77 | </dd>
|
---|
78 | <dt><code>#include "<var>file</var>"</code></dt>
|
---|
79 | <dd><p>This variant is used for header files of your own program. It
|
---|
80 | searches for a file named <var>file</var> first in the directory containing
|
---|
81 | the current file, then in the quote directories, then the same
|
---|
82 | directories used for <code><<var>file</var>></code>. You can prepend directories
|
---|
83 | to the list of quote directories with the <samp>-iquote</samp> option.
|
---|
84 | </p></dd>
|
---|
85 | </dl>
|
---|
86 |
|
---|
87 | <p>The argument of <code>#include</code>, whether delimited with quote marks or
|
---|
88 | angle brackets, behaves like a string constant in that comments are not
|
---|
89 | recognized, and macro names are not expanded. Thus, <code>#include <x/*y><!-- /@w --></code> specifies inclusion of a system header file named <samp>x/*y</samp>.
|
---|
90 | </p>
|
---|
91 | <p>However, if backslashes occur within <var>file</var>, they are considered
|
---|
92 | ordinary text characters, not escape characters: character escape
|
---|
93 | sequences such as used in string constants in C are not meaningful
|
---|
94 | here. Thus, <code>#include "x\n\\y"<!-- /@w --></code> specifies a filename
|
---|
95 | containing three backslashes. By the same token, there is no way to
|
---|
96 | escape ‘<samp>"</samp>’ or ‘<samp>></samp>’ to include it in the header file name if
|
---|
97 | it would instead end the file name.
|
---|
98 | </p>
|
---|
99 | <p>Some systems interpret ‘<samp>\</samp>’ as a file name component separator.
|
---|
100 | All these systems also interpret ‘<samp>/</samp>’ the same way. It is most
|
---|
101 | portable to use only ‘<samp>/</samp>’.
|
---|
102 | </p>
|
---|
103 | <p>It is an error to put anything other than comments on the
|
---|
104 | <code>#include</code> line after the file name.
|
---|
105 | </p>
|
---|
106 | <hr>
|
---|
107 | <div class="header">
|
---|
108 | <p>
|
---|
109 | Next: <a href="include-Operation.html" accesskey="n" rel="next">include Operation</a>, Up: <a href="Header-Files.html" accesskey="u" rel="up">Header Files</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>
|
---|
110 | </div>
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 | </body>
|
---|
115 | </html>
|
---|