Documentation/coding_style: Add more details on include-ordering
This patch is trying to address some of the concerns raised in CB:50247 after the patch had landed. The preference for alphabetized headers was just supposed to discourage leaving headers completely unordered, and wasn't intended to disallow other intentional include orderings such as grouping local includes after system ones or specific ordering constraints that exist for technical reasons. This patch adds a few more sentences to try to clarify that. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I6825f4a57613fabb88a00ae46679b4774ef7110b Reviewed-on: https://review.coreboot.org/c/coreboot/+/51553 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
96094b31e9
commit
698b05fdd5
|
@ -837,14 +837,16 @@ pointers; they use NULL or the ERR_PTR mechanism to report failure.
|
||||||
Headers and includes
|
Headers and includes
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Headers should always be included at the top of the file, preferrably in
|
Headers should always be included at the top of the file. Includes should
|
||||||
alphabetical order. Includes should always use the `#include <file.h>`
|
always use the `#include <file.h>` notation, except for rare cases where a file
|
||||||
notation, except for rare cases where a file in the same directory that
|
in the same directory that is not part of a normal include path gets included
|
||||||
is not part of a normal include path gets included (e.g. local headers
|
(e.g. local headers in mainboard directories), which should use `#include
|
||||||
in mainboard directories), which should use `#include "file.h"`. Headers
|
"file.h"`. Local "file.h" includes should always come separately after all
|
||||||
that can be included from both assembly files and .c files should keep
|
<file.h> includes. Headers that can be included from both assembly files and
|
||||||
all C code wrapped in `#ifndef __ASSEMBLER__` blocks, including includes
|
.c files should keep all C code wrapped in `#ifndef __ASSEMBLER__` blocks,
|
||||||
to other headers that don't follow that provision.
|
including includes to other headers that don't follow that provision. Where a
|
||||||
|
specific include order is required for technical reasons, it should be clearly
|
||||||
|
documented with comments.
|
||||||
|
|
||||||
Files should generally include every header they need a definition from
|
Files should generally include every header they need a definition from
|
||||||
directly (and not include any unnecessary extra headers). Excepted from
|
directly (and not include any unnecessary extra headers). Excepted from
|
||||||
|
|
Loading…
Reference in New Issue