include Files

The #include preprocessor directive allows you to retrieve source statements from secondary input files and incorporate them into your program.

Compiler options and environment variables let you choose the disk directories searched by the compiler when it looks for include files.

Syntax

#include  < filename >  " filename " 

Angle brackets indicate a system include file, and quotation marks indicate a user include file.

File Name Syntax
You can specify any valid filename in an #include directive. The filename must be sufficiently qualified (have enough of a path) for the compiler to be able to locate it. In some cases, an unqualified or partially qualified filename may be sufficient, for example:

   #include "..\HEADERS\myheader.h"

In other cases, you may have to include the entire path name.

If a path name is too long to fit on one line, use a backslash (\) as a continuation character to indicate that the current line continues onto the next line. The backslash can follow or precede a directory separator, or divide a name. For example, to include the following file as a user include file:

   c:\cset\include\mystuff\subdir1\subdir2\subdir3\myfile.h

you could insert one of the following #include directives in your program:

   #include "c:\cset\include\mystuff\subdir1\sub\
   dir2\subdir3\myfile.h"

or

   #include "c:\cset\include\mystuff\subdir1\\
   subdir2\subdir3\myfile.h"

Restrictions:

  1. The continuation character (\)must be the last non-white-space character on the line. (White space includes any of the space, tab, new-line, or form-feed characters.) The line cannot contain a comment.
  2. The continuation character (\), although the same character as the directory separator, does not take the place of a directory separator or imply a new directory.


Initial Sequence of Headers


include Search Paths
Environment Variables for Compiling
Summary of Compiler Options by Function