Go Up to Preprocessor Directives Index
#include <header_name> #include "header_name" #include <macro_definition>
For information about #include syntax with Clang-enhanced C++ compilers, see Clang-enhanced C++ Compilers, #include Paths and Lookup.
The #include directive pulls in other named files (known as include files, header files or headers) into the source code. The syntax has three versions:
- The first and second versions imply that no macro expansion will be attempted; in other words,
header_nameis never scanned for macro identifiers.
header_namemust be a valid file name with an extension (traditionally .h for header files) and optional path name and path delimiters.
- The third version assumes that neither
"appears as the first non-whitespace character following #include; further, it assumes a macro definition exists that will expand the macro identifier into a valid delimited header name with either of the
The preprocessor removes the #include line and conceptually replaces it with the entire text of the include file at that point in the source code. The source code itself is not changed, but the compiler "sees" the enlarged text. The placement of the #include can therefore influence the scope and duration of any identifiers in the included file.
If you place an explicit path in the
header_name, only that directory will be searched.
The difference between the
"header_name" formats lies in the searching algorithm employed in trying to locate the include file:
|Syntax Form||Searching Algorithm|