Header Files

Header files contain information needed by the compiler telling it about functions and macros not present in a .c file. By convention, they are named with a .h extention.

Header files DO NOT contain executable C code.

The contain only prototype statments and macro definitions.

We include the information in a header file in a .c file using the #include compiler directive. We have already seen one instance of this directive:

     #include <stdio.h>

The < > brackets say that the header file is a system file, located in "the usual place" in the file system where header files are stored (usually /usr/include on unix systems).

We can include our own header files as well:

     #include "tfdef.h"

This tells the compiler to find the header file in the current directory.

The include directive tells the C preprocessor to get that header and put it in place of the directive as if it were typed there before beginning to translate the code.


[up] to Overview.