Skip to content

Commit 63ceef6

Browse files
authored
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
1 parent 6388b4d commit 63ceef6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CppCoreGuidelines.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18743,6 +18743,7 @@ Source file rule summary:
1874318743
* [SF.9: Avoid cyclic dependencies among source files](#Rs-cycles)
1874418744
* [SF.10: Avoid dependencies on implicitly `#include`d names](#Rs-implicit)
1874518745
* [SF.11: Header files should be self-contained](#Rs-contained)
18746+
* [SF.12: Prefer the angle bracket form of `#include` where you can and the quoted form everywhere else](#Rs-incform)
1874618747

1874718748
* [SF.20: Use `namespace`s to express logical structure](#Rs-namespace)
1874818749
* [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
1918119182

1918219183
A test should verify that the header file itself compiles or that a cpp file which only includes the header file compiles.
1918319184

19185+
### <a name="Rs-incform"></a>SF.12: Prefer the angle bracket form of `#include` where you can and the quoted form everywhere else
19186+
19187+
##### Reason
19188+
19189+
The [standard](http://eel.is/c++draft/cpp.include) provides flexibility for compilers to implement
19190+
the two forms of `#include` selected using the angle (`<>`) or quoted (`""`) syntax. Vendors take
19191+
advantage of this and use different search algorithms and methods for specifying the include path.
19192+
19193+
Never the less, the guidance is to use the angle form when possible. This supports the fact that the
19194+
standard library headers must be included this way, is more likely to create portable code, and enables
19195+
the quoted form for other uses. For example being clear about the locality of the header relative
19196+
to files that includes it or in scenarios where the different search algorithm is required.
19197+
19198+
##### Example
19199+
19200+
#include <string> // From the standard library, required form
19201+
#include "helpers.h" // A project specific file, use "" form
19202+
19203+
##### Note
19204+
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.
19205+
19206+
Library creators should put their headers in a folder and have clients include those files using the relative path `#include <some_library/common.h>`
19207+
19208+
##### Enforcement
19209+
19210+
A test should identify headers referenced via `""` could be referenced with `<>`.
19211+
1918419212
### <a name="Rs-namespace"></a>SF.20: Use `namespace`s to express logical structure
1918519213

1918619214
##### Reason

scripts/hunspell/isocpp.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ impactful
240240
impl
241241
Impl
242242
implicitpointercast
243+
incform
243244
incomplet
244245
incorrekt
245246
increment1

0 commit comments

Comments
 (0)