Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/71612 )
Change subject: contributing/coding_style.md: Add and clarify includes rules ......................................................................
contributing/coding_style.md: Add and clarify includes rules
Change-Id: I3af2c3b15dda7e8b095767084dae8ee24d478256 Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M Documentation/contributing/coding_style.md 1 file changed, 33 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/71612/1
diff --git a/Documentation/contributing/coding_style.md b/Documentation/contributing/coding_style.md index 5b2919e3..e1199d8 100644 --- a/Documentation/contributing/coding_style.md +++ b/Documentation/contributing/coding_style.md @@ -921,9 +921,29 @@ "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. +including includes to other headers that don't follow that provision. +The includes should be ordered alphabetically. Where a specific include order is +required for technical reasons, it should be clearly documented with comments. +Don't use UNIX directory '.' or '..' shortcuts and put conditional includes +after the other includes. + +Example: +```c +#include <related_headers.h> +#ifdef CONDITION +#include <conditional_headers.h> +#endif +One blank line +#include "local_headers.h" +#ifdef LOCAL_CONDITION +#include "local_conditional_headers.h" +#endif +One blank line +#include <vendorcode/headers.h> +#ifdef VENDOR_CONDITION +#include <vendor_conditional_headers.h> +#endif +```
Files should generally include every header they need a definition from directly (and not include any unnecessary extra headers). Excepted from