|
|
1.1 root 1:
2:
3: #include Preprocessing Directive #include
4:
5:
6:
7:
8: Read another file and include it
9:
10: #iinncclluuddee <_f_i_l_e>
11: #iinncclluuddee "_f_i_l_e"
12:
13: The preprocessing directive #include tells the preprocessor to
14: replace the directive with the contents of file.
15:
16: The directive can take one of two forms: either the name of the
17: file is enclosed within angle brackets (<_h_e_a_d_e_r.hh>), or it is
18: enclosed within quotation marks ("_h_e_a_d_e_r.hh"). Angle brackets
19: tell cpp to look for _f_i_l_e.hh in the directories named with the -II
20: options to the cc command line, and then in the standard direc-
21: tory. Quotation marks tell cpp to look for _f_i_l_e.hh in the source
22: file's directory, then in directories named with the -II options,
23: and then in the standard directory.
24:
25: Most often, the file being included is a header, which is a file
26: that contains function prototypes, macro definitions, and other
27: useful material; as its name implies, it most often appears at
28: the head of a program. The header name must be a string of
29: characters, possibly followed by a period `.' and a single let-
30: ter, usually (but not always) `h'. A header name may have up to
31: 12 characters to the left of the period, and names may be case
32: sensitive.
33:
34: #include directives may be nested up to at least eight deep.
35: That is to say, a file included by an #include directive may use
36: an #include directive to include a third file; that third file
37: may also use a #include directive to include a fourth file; and
38: so on, up to at least eight files.
39:
40: Note, too, that a subordinate header file is sought relative to
41: the original source file, rather than relative to the header that
42: calls it directly. For example, suppose that a file example.c
43: resides in directory /v/fred/src. If example.c contains the
44: directive #include <header1.h>. The operating system will look
45: for header1.h in the standard directory, /usr/include. If
46: header1.h includes the directive #include <../header2.h> then
47: COHERENT looks for header2.h not in directory /uussrr, but in direc-
48: tory /v/fred.
49:
50: A #include directive may also take the form #iinncclluuddee _s_t_r_i_n_g,
51: where string is a macro that expands into either of the two forms
52: described above.
53:
54: ***** See Also *****
55:
56: header files, C preprocessor
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.