This chapter explains what to and what not to keep in header files. In general, when we want to share data between multiple source files, we create a common header file and include it in each source file. For the following
examples, we will use two source files and one common header file:
myheaderfile.h – Shared header file
source.c – Main source file
source2.c – Second source file
A good practice is to guard the content of the
myheaderfile.h file with the
include guards/header guards:
#ifndef MYHEADERFILE_H ...