Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/51553 )
Change subject: Documentation/coding_style: Add more details on include-ordering ......................................................................
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 --- M Documentation/contributing/coding_style.md 1 file changed, 10 insertions(+), 8 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
diff --git a/Documentation/contributing/coding_style.md b/Documentation/contributing/coding_style.md index 5f87a3f..f6a0f54 100644 --- a/Documentation/contributing/coding_style.md +++ b/Documentation/contributing/coding_style.md @@ -837,14 +837,16 @@ 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