From 63ceef65e37a100f9b5c9df735e0e9717b22a024 Mon Sep 17 00:00:00 2001 From: Chris Guzak Date: Thu, 27 Feb 2020 11:16:10 -0800 Subject: [PATCH] Add SF.12, 3rd try (#1570) * add SF.12 * add incscope to isocpp.dic to get the CI build to pass * expand INCLUDES, update dictionary for the ci build to pass * pr feedback * in the same directory * update based on feedback * 3rd try * PR feedback * update lable * Update CppCoreGuidelines.md * Update CppCoreGuidelines.md --- CppCoreGuidelines.md | 28 ++++++++++++++++++++++++++++ scripts/hunspell/isocpp.dic | 1 + 2 files changed, 29 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index d0bf87d..5b0581e 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -18743,6 +18743,7 @@ Source file rule summary: * [SF.9: Avoid cyclic dependencies among source files](#Rs-cycles) * [SF.10: Avoid dependencies on implicitly `#include`d names](#Rs-implicit) * [SF.11: Header files should be self-contained](#Rs-contained) +* [SF.12: Prefer the angle bracket form of `#include` where you can and the quoted form everywhere else](#Rs-incform) * [SF.20: Use `namespace`s to express logical structure](#Rs-namespace) * [SF.21: Don't use an unnamed (anonymous) namespace in a header](#Rs-unnamed) @@ -19181,6 +19182,33 @@ A header should include all its dependencies. Be careful about using relative pa A test should verify that the header file itself compiles or that a cpp file which only includes the header file compiles. +### SF.12: Prefer the angle bracket form of `#include` where you can and the quoted form everywhere else + +##### Reason + +The [standard](http://eel.is/c++draft/cpp.include) provides flexibility for compilers to implement +the two forms of `#include` selected using the angle (`<>`) or quoted (`""`) syntax. Vendors take +advantage of this and use different search algorithms and methods for specifying the include path. + +Never the less, the guidance is to use the angle form when possible. This supports the fact that the +standard library headers must be included this way, is more likely to create portable code, and enables +the quoted form for other uses. For example being clear about the locality of the header relative +to files that includes it or in scenarios where the different search algorithm is required. + +##### Example + + #include // From the standard library, required form + #include "helpers.h" // A project specific file, use "" form + +##### Note +Failing to follow this results in difficult to diagnose errors due to picking up the wrong file by incorrectly specifying the scope when it is included. + +Library creators should put their headers in a folder and have clients include those files using the relative path `#include ` + +##### Enforcement + +A test should identify headers referenced via `""` could be referenced with `<>`. + ### SF.20: Use `namespace`s to express logical structure ##### Reason diff --git a/scripts/hunspell/isocpp.dic b/scripts/hunspell/isocpp.dic index b11c910..9623926 100644 --- a/scripts/hunspell/isocpp.dic +++ b/scripts/hunspell/isocpp.dic @@ -240,6 +240,7 @@ impactful impl Impl implicitpointercast +incform incomplet incorrekt increment1