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:
Julius Werner 2021-03-16 16:47:05 -07:00 committed by Patrick Georgi
parent 96094b31e9
commit 698b05fdd5
1 changed files with 10 additions and 8 deletions

View File

@ -837,14 +837,16 @@ pointers; they use NULL or the ERR_PTR mechanism to report failure.
Headers and includes
---------------
Headers should always be included at the top of the file, preferrably in
alphabetical order. Includes should always use the `#include <file.h>`
notation, except for rare cases where a file in the same directory that
is not part of a normal include path gets included (e.g. local headers
in mainboard directories), which should use `#include "file.h"`. Headers
that can be included from both assembly files and .c files should keep
all C code wrapped in `#ifndef __ASSEMBLER__` blocks, including includes
to other headers that don't follow that provision.
Headers should always be included at the top of the file. Includes should
always use the `#include <file.h>` notation, except for rare cases where a file
in the same directory that is not part of a normal include path gets included
(e.g. local headers in mainboard directories), which should use `#include
"file.h"`. Local "file.h" includes should always come separately after all
<file.h> includes. Headers that can be included from both assembly files and
.c files should keep all C code wrapped in `#ifndef __ASSEMBLER__` blocks,
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
directly (and not include any unnecessary extra headers). Excepted from