#include Directive
Preprocessor directive that inserts the contents of the specified file into the source program at the point where the directive appears.
#include "filename" |
---|
#include <filename> |
Parameters
Item | Description |
---|---|
filename | Filename of the file to include, optionally preceded by a directory specification. The filename must specify an existing file. |
Remarks
The #include directive causes replacement of the directive by the entire contents of the specified file. The preprocessor stops searching as soon as it finds a file with the specified name; if you specify a complete, unambiguous path specification for the file, the preprocessor searches only the specified path.
Note
The Effect-Compiler Tool has a built-in include handler using the /I switch. However, when executing the compiler from the API, you can provide a customized include handler by implementing the ID3DXInclude interface.
The difference between the two syntax forms is the order in which the preprocessor searches for header files when the path is incompletely specified, as shown in the following table.
Syntax form | Preprocessor search pattern |
---|---|
#include "filename" | Searches for the include file:
|
#include <filename> | Searches for the include file:
|
Examples
The following example causes the preprocessor to replace the #include directive with the contents of stdio.h. Because the example uses the angle bracket format, the preprocessor will search for the file only in the directories listed by the /I compiler option and the INCLUDE environment variable.
#include <stdio.h>