Source file inclusion
Includes another source file into the current source file at the line immediately after the directive.
Contents |
[edit] Syntax
#include < filename>
|
(1) | ||||||||
#include " filename"
|
(2) | ||||||||
[edit] Explanation
Includes source file, identified by filename, into the current source file at the line immediately after the directive.
1) Searches for the file in implementation-defined manner. The intent of this syntax is to search for the files under control of the implementation. Typical implementations search only standard include directories. The standard C++ library and the standard C library are implicitly included in these standard include directories. The standard include directories usually can be controlled by the user through compiler options.
2) Searches for the file in implementation-defined manner. The intent of this syntax is to search for the files that are not controlled by the implementation. Typical implementations first search the directory where the current file resides and, only if the file is not found, search the standard include directories as with (1).
In the case the file is not found, the program is ill-formed.
[edit] References
- C17 standard (ISO/IEC 9899:2018):
- 6.10.2 Source file inclusion (p: 119-120)
- C11 standard (ISO/IEC 9899:2011):
- 6.10.2 Source file inclusion (p: 164-166)
- C99 standard (ISO/IEC 9899:1999):
- 6.10.2 Source file inclusion (p: 149-151)
- C89/C90 standard (ISO/IEC 9899:1990):
- 3.8.2 Source file inclusion
[edit] See also
A list of C Standard Library header files | |
C++ documentation for Source file inclusion
|