Next: , Previous: Header files, Up: Writing modules


4.3 Implementation files

The .c file or files implement the functions and variables declared in the .h file.

Include ordering

Every implementation file must start with ‘#include <config.h>’. This is necessary for activating the preprocessor macros that are defined on behalf of the Autoconf macros. Some of these preprocessor macros, such as _GNU_SOURCE, would have no effect if defined after a system header file has already been included.

Then comes the ‘#include "..."’ specifying the header file that is being implemented. Putting this right after ‘#include <config.h>’ has the effect that it verifies that the header file is self-contained.

Then come the system and application headers. It is customary to put all the system headers before all application headers, so as to minimize the risk that a preprocessor macro defined in an application header confuses the system headers on some platforms.

In summary: