diff options
author | Julius Werner <jwerner@chromium.org> | 2021-03-16 16:47:05 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-03-22 11:30:13 +0000 |
commit | 698b05fdd506266ed61f93a67a273c2288bd2323 (patch) | |
tree | 53ea524baffc374ceb677182aece165c09bc15a5 /Documentation/contributing | |
parent | 96094b31e925f38455e2d983991305111de068f0 (diff) |
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>
Diffstat (limited to 'Documentation/contributing')
-rw-r--r-- | Documentation/contributing/coding_style.md | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Documentation/contributing/coding_style.md b/Documentation/contributing/coding_style.md index 5f87a3f389..f6a0f540b8 100644 --- a/Documentation/contributing/coding_style.md +++ b/Documentation/contributing/coding_style.md @@ -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 |