Skip to content

Reorganize #include

Extends previous merge request !224 (merged).

Header file order

The order of includes should not matter if all headers were self-contained, but there's a specific order that helps detect and fix headers that are not self-contained. Why choose the opposite order? See:

Include <config.h> vs. "config.h"

We have a mixture of:

#include "config.h"
#include <config.h>

I personally prefer "config.h", but the autoconf manual states:

The package should ‘#include’ the configuration header file before any other header files, to prevent inconsistencies in declarations (for example, if it redefines const).

To provide for VPATH builds, remember to pass the C compiler a -I. option (or -I..; whichever directory contains config.h). Even if you use ‘#include "config.h"’, the preprocessor searches only the directory of the currently read file, i.e., the source directory, not the build directory.

With the appropriate -I option, you can use ‘#include <config.h>’. Actually, it's a good habit to use it, because in the rare case when the source directory contains another config.h, the build directory should be searched first. I will therefore change to <config.h>.

Edited by Dimitri Papadopoulos Orfanos

Merge request reports