C - File Inclusion
Revision as of 06:51, 7 March 2012 by Jshankar (1 revision)
- A control line of the form #include “filename” OR #include <filename>, causes the replacement of that line by the entire contents of the file filename.
- If the filename is quoted, searching for the file typically begins where the source program was found; if it is not found there, or if the name is enclosed in < and >, searching follows an implementation defined rule to find the file.
- An included file may itself contain #include lines
- There are often several #include lines at the beginning of a source file, to include common #define statements and extern declarations; or to access the function prototypes declarations for library functions from headers like <stdio.h>
- #include is the preferred way to tie the declarations together for a program. It guarantees that all the source files will be supplied with the same definitions and variable declarations, and thus eliminates a particularly nasty kind of bug.