You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CppCoreGuidelines.md
+15-3
Original file line number
Diff line number
Diff line change
@@ -19296,7 +19296,13 @@ The [standard](http://eel.is/c++draft/cpp.include) provides flexibility for comp
19296
19296
the two forms of `#include` selected using the angle (`<>`) or quoted (`""`) syntax. Vendors take
19297
19297
advantage of this and use different search algorithms and methods for specifying the include path.
19298
19298
19299
-
Nevertheless, the guidance is to use the quoted form for including files that exist at a relative path to the file containing the `#include` statement (from within the same component or project) and to use the angle bracket form everywhere else, where possible. This encourages being clear about the locality of the file relative to files that include it, or scenarios where the different search algorithm is required. It makes it easy to understand at a glance whether a header is being included from a local relative file versus a standard library header or a header from the alternate search path (e.g. a header from another library or a common set of includes).
19299
+
Nevertheless, the guidance is to use the quoted form for including files that exist at a relative path
19300
+
to the file containing the `#include` statement (from within the same component or project) and to use
19301
+
the angle bracket form everywhere else, where possible. This encourages being clear about the locality
19302
+
of the file relative to files that include it, or scenarios where the different search algorithm is
19303
+
required. It makes it easy to understand at a glance whether a header is being included from a local
19304
+
relative file versus a standard library header or a header from the alternate search path (e.g. a header
19305
+
from another library or a common set of includes).
19300
19306
19301
19307
##### Example
19302
19308
@@ -19309,9 +19315,15 @@ Nevertheless, the guidance is to use the quoted form for including files that ex
19309
19315
19310
19316
##### Note
19311
19317
19312
-
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. For example, in a typical case where the `#include ""` search algorithm might search for a file existing at a local relative path first, then using this form to refer to a file that is not locally relative could mean that if a file ever comes into existence at the local relative path (e.g. the including file is moved to a new location), it will now be found ahead of the previous include file and the set of includes will have been changed in an unexpected way.
19318
+
Failing to follow this results in difficult to diagnose errors due to picking up the wrong file by
19319
+
incorrectly specifying the scope when it is included. For example, in a typical case where the `#include ""`
19320
+
search algorithm might search for a file existing at a local relative path first, then using this form to refer
19321
+
to a file that is not locally relative could mean that if a file ever comes into existence at the
19322
+
local relative path (e.g. the including file is moved to a new location), it will now be found ahead
19323
+
of the previous include file and the set of includes will have been changed in an unexpected way.
19313
19324
19314
-
Library creators should put their headers in a folder and have clients include those files using the relative path `#include <some_library/common.h>`
19325
+
Library creators should put their headers in a folder and have clients include those files using the
0 commit comments