[Main]
Title=Header Files
Subsections=SEC6, SEC7, SEC8, SEC8a, SEC9, SEC9a

[Top]
A header file is a file containing C declarations and macro definitions
(see <A HREF="$$LINK(SEC10)">Macros</A>) to be shared between several source files.  You request
the use of a header file in your program by <U>including</U> it, with the
C preprocessing directive <CODE>#include</CODE>.
<BR><BR>
Header files serve two purposes.
<UL>
<LI>
System header files declare the interfaces to parts of the operating
system.  You include them in your program to supply the definitions and
declarations you need to invoke system calls and libraries.
<BR><BR>
</LI>
<LI>
Your own header files contain declarations for interfaces between the
source files of your program.  Each time you have a group of related
declarations and macro definitions all or most of which are needed in
several different source files, it is a good idea to create a header
file for them.
</LI>
</UL>
Including a header file produces the same results as copying the header
file into each source file that needs it.  Such copying would be
time-consuming and error-prone.  With a header file, the related
declarations appear in only one place.  If they need to be changed, they
can be changed in one place, and programs that include the header file
will automatically use the new version when next recompiled.  The header
file eliminates the labor of finding and changing all the copies as well
as the risk that a failure to find one copy will result in
inconsistencies within a program.
<BR><BR>
In C, the usual convention is to give header files names that end with
<CODE>.h</CODE>.  It is most portable to use only letters, digits, dashes, and
underscores in header file names, and at most one dot.
