In C and its derivatives,1 a header file consists of several handy data types and functions that extend the capability of our base code.

Header files will never contain executable code, and will never contain variable declarations. They may contain type definitions and function prototypes. The functions that are declared will be defined in a corresponding .cpp file that #include the header file. Then, whenever we invoke the header file, the functions are properly defined.

We invoke them through preprocessor directives. For instance:

#include <stdio.h>
#include <stdlib.h>

which searches for files within the standard library.

Note that we can define our own header files as well — this is especially useful for multi-file projects. We can instead #include inside quotation marks (which will search inside the current directory):

#include "bar.h"

List

Some important included header files are:

Footnotes

  1. C++/Verilog/SystemVerilog