|
|
coherent
#include Preprocessing Directive #include
Read another file and include it
#iinncclluuddee <_f_i_l_e>
#iinncclluuddee "_f_i_l_e"
The preprocessing directive #include tells the preprocessor to
replace the directive with the contents of file.
The directive can take one of two forms: either the name of the
file is enclosed within angle brackets (<_h_e_a_d_e_r.hh>), or it is
enclosed within quotation marks ("_h_e_a_d_e_r.hh"). Angle brackets
tell cpp to look for _f_i_l_e.hh in the directories named with the -II
options to the cc command line, and then in the standard direc-
tory. Quotation marks tell cpp to look for _f_i_l_e.hh in the source
file's directory, then in directories named with the -II options,
and then in the standard directory.
Most often, the file being included is a header, which is a file
that contains function prototypes, macro definitions, and other
useful material; as its name implies, it most often appears at
the head of a program. The header name must be a string of
characters, possibly followed by a period `.' and a single let-
ter, usually (but not always) `h'. A header name may have up to
12 characters to the left of the period, and names may be case
sensitive.
#include directives may be nested up to at least eight deep.
That is to say, a file included by an #include directive may use
an #include directive to include a third file; that third file
may also use a #include directive to include a fourth file; and
so on, up to at least eight files.
Note, too, that a subordinate header file is sought relative to
the original source file, rather than relative to the header that
calls it directly. For example, suppose that a file example.c
resides in directory /v/fred/src. If example.c contains the
directive #include <header1.h>. The operating system will look
for header1.h in the standard directory, /usr/include. If
header1.h includes the directive #include <../header2.h> then
COHERENT looks for header2.h not in directory /uussrr, but in direc-
tory /v/fred.
A #include directive may also take the form #iinncclluuddee _s_t_r_i_n_g,
where string is a macro that expands into either of the two forms
described above.
***** See Also *****
header files, C preprocessor
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.