The #include directive tells the preprocessor to treat the  contents of a specified file as if those contents had appeared in the  source program at the point where the directive appears. 
You can  organize constant and macro definitions into include files and then use #include  directives to add these definitions to any source file. Include files  are also useful for incorporating declarations of external variables and  complex data types. You need to define and name the types only once in  an include file created for that purpose.
The path-spec is a filename optionally preceded by a directory specification. The filename must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
Both syntax forms cause replacement of that directive by the entire  contents of the specified include file. The difference between the two  forms is the order in which the preprocessor searches for header files  when the path is incompletely specified.
| Syntax Form | Action | ||||||
|---|---|---|---|---|---|---|---|
| Quoted form | This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of any files that include (#include)  that file. The preprocessor then searches along the path specified by  the /I compiler option, then along paths specified by the INCLUDE  environment variable. Example #include "defs.h" | ||||||
| Angle-bracket form | This  form instructs the preprocessor to search for include files first along  the path specified by the /I compiler option, then, when compiling from  the command line, along the path specified by the INCLUDE environment  variable. Example #include <stdio.h> | 
 
No comments:
Post a Comment