source: public/doc/gnu-c/include-Syntax.html@ 02598c2

Last change on this file since 02598c2 was 02598c2, checked in by Mikhail Kirillov <w96k@…>, on Oct 6, 2022 at 12:36:29 PM

Add gnu-c

  • Property mode set to 100644
File size: 5.4 KB
Line 
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
6licensed to the FSF.)
7
8Permission is granted to copy, distribute and/or modify this document
9under the terms of the GNU Free Documentation License, Version 1.3 or
10any later version published by the Free Software Foundation; with the
11Invariant Sections being "GNU General Public License," with the
12Front-Cover Texts being "A GNU Manual," and with the Back-Cover
13Texts as in (a) below. A copy of the license is included in the
14section entitled "GNU Free Documentation License."
15
16(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
17modify this GNU manual. Buying copies from the FSF supports it in
18developing 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<!--
37a.summary-letter {text-decoration: none}
38blockquote.indentedblock {margin-right: 0em}
39div.display {margin-left: 3.2em}
40div.example {margin-left: 3.2em}
41div.lisp {margin-left: 3.2em}
42kbd {font-style: oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47span.nolinebreak {white-space: nowrap}
48span.roman {font-family: initial; font-weight: normal}
49span.sansserif {font-family: sans-serif; font-weight: normal}
50ul.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>
60Next: <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> &nbsp; [<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
67preprocessing directive <code>#include</code>. It has two variants:
68</p>
69<dl compact="compact">
70<dt><code>#include &lt;<var>file</var>&gt;</code></dt>
71<dd><p>This variant is used for system header files. It searches for a file
72named <var>file</var> in a standard list of system directories. You can
73prepend 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
75Compiler Collection</cite>).
76</p>
77</dd>
78<dt><code>#include &quot;<var>file</var>&quot;</code></dt>
79<dd><p>This variant is used for header files of your own program. It
80searches for a file named <var>file</var> first in the directory containing
81the current file, then in the quote directories, then the same
82directories used for <code>&lt;<var>file</var>&gt;</code>. You can prepend directories
83to 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
88angle brackets, behaves like a string constant in that comments are not
89recognized, and macro names are not expanded. Thus, <code>#include&nbsp;&lt;x/*y&gt;<!-- /@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
92ordinary text characters, not escape characters: character escape
93sequences such as used in string constants in C are not meaningful
94here. Thus, <code>#include&nbsp;&quot;x\n\\y&quot;<!-- /@w --></code> specifies a filename
95containing three backslashes. By the same token, there is no way to
96escape &lsquo;<samp>&quot;</samp>&rsquo; or &lsquo;<samp>&gt;</samp>&rsquo; to include it in the header file name if
97it would instead end the file name.
98</p>
99<p>Some systems interpret &lsquo;<samp>\</samp>&rsquo; as a file name component separator.
100All these systems also interpret &lsquo;<samp>/</samp>&rsquo; the same way. It is most
101portable to use only &lsquo;<samp>/</samp>&rsquo;.
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>
109Next: <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> &nbsp; [<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>
Note: See TracBrowser for help on using the repository browser.