8.3 File Inclusion (#include)

The #include directive inserts the contents of a specified file into the text stream delivered to the compiler. Usually, standard headers and global definitions are included in the program stream with the #include directive. This directive has two forms:

#include "filename" newline
#include <filename> newline

The format of filename is platform-dependent. If the filename is enclosed in quotation marks, the search for the named file begins in the directory where the file containing the #include directive resides. If the file is not found there, or if the file name is enclosed in angle brackets (< >), the file search follows platform-defined search rules. In general, the quoted form of #include is used to include files written by users, while the bracketed form is used to include standard library files.

See your platform-specific DEC C documentation for information on the search path rules used for file inclusion.

Macro substitution is allowed within the #include preprocessor directive.

For example, the following two directives can be used to include a file:

#define  macro1  "file.ext"

#include macro1

Defined macros used in #include directives must evaluate to one of the two following acceptable #include file specifications or an error is reported:

"filename"
<filename>

An included file may itself contain #include directives. Although the DEC C compiler imposes no inherent limitation on the nesting level of inclusion, the permitted depth depends on hardware and operating system restrictions.


Previous Page | Next Page | Table of Contents | Index