C - File Inclusion

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

File Inclusion

  • 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.