source: public/doc/gnu-c/include-Operation.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.2 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 Operation (GNU C Language Manual)</title>
23
24<meta name="description" content="include Operation (GNU C Language Manual)">
25<meta name="keywords" content="include Operation (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="Search-Path.html" rel="next" title="Search Path">
34<link href="include-Syntax.html" rel="prev" title="include Syntax">
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-Operation"></span><div class="header">
59<p>
60Next: <a href="Search-Path.html" accesskey="n" rel="next">Search Path</a>, Previous: <a href="include-Syntax.html" accesskey="p" rel="prev">include Syntax</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-Operation"></span><h4 class="subsection">26.4.2 <code>#include</code> Operation</h4>
64
65<p>The <code>#include</code> directive works by scanning the specified header
66file as input before continuing with the rest of the current file.
67The result of preprocessing consists of the text already generated,
68followed by the result of preprocessing the included file, followed by
69whatever results from the text after the <code>#include</code> directive.
70For example, if you have a header file <samp>header.h</samp> as follows,
71</p>
72<div class="example">
73<pre class="example">char *test (void);
74</pre></div>
75
76<p>and a main program called <samp>program.c</samp> that uses the header file,
77like this,
78</p>
79<div class="example">
80<pre class="example">int x;
81#include &quot;header.h&quot;
82
83int
84main (void)
85{
86 puts (test ());
87}
88</pre></div>
89
90<p>the result is equivalent to putting this text in <samp>program.c</samp>:
91</p>
92<div class="example">
93<pre class="example">int x;
94char *test (void);
95
96int
97main (void)
98{
99 puts (test ());
100}
101</pre></div>
102
103<p>Included files are not limited to declarations and macro definitions;
104those are merely the typical uses. Any fragment of a C program can be
105included from another file. The include file could even contain the
106beginning of a statement that is concluded in the containing file, or
107the end of a statement that was started in the including file. However,
108an included file must consist of complete tokens. Comments and string
109literals that have not been closed by the end of an included file are
110invalid. For error recovery, the compiler terminates them at the end of
111the file.
112</p>
113<p>To avoid confusion, it is best if header files contain only complete
114syntactic units&mdash;function declarations or definitions, type
115declarations, etc.
116</p>
117<p>The line following the <code>#include</code> directive is always treated as
118a separate line, even if the included file lacks a final newline.
119There is no problem putting a preprocessing directive there.
120</p>
121<hr>
122<div class="header">
123<p>
124Next: <a href="Search-Path.html" accesskey="n" rel="next">Search Path</a>, Previous: <a href="include-Syntax.html" accesskey="p" rel="prev">include Syntax</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>
125</div>
126
127
128
129</body>
130</html>
Note: See TracBrowser for help on using the repository browser.