

#include             Preprocessing Directive             #include




Read another file and include it

#iinncclluuddee <_f_i_l_e>
#iinncclluuddee "_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.hh>), or  it is
enclosed  within quotation  marks  ("_h_e_a_d_e_r.hh").  Angle  brackets
tell cpp to look for _f_i_l_e.hh in the directories  named with the -II
options to the cc command line,  and then in the  standard direc-
tory.  Quotation marks tell cpp  to look for _f_i_l_e.hh in the source
file's directory, then in directories named with the  -II 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 /uussrr, but in direc-
tory /v/fred.

A  #include directive  may also  take  the form  #iinncclluuddee _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


