From 30ef5b852460207d2fd0aca6754eb073f10574f8 Mon Sep 17 00:00:00 2001 From: apenn-msft <62863214+apenn-msft@users.noreply.github.com> Date: Fri, 3 Apr 2020 14:19:18 -0700 Subject: [PATCH] update code markdown for #include --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 24578f9..dbf8722 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -19190,7 +19190,7 @@ The [standard](http://eel.is/c++draft/cpp.include) provides flexibility for comp 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. -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' and to use the angle bracket form everywhere else, where possible. This encourages being clear about the locality of the header relative to files that include it, or scenarios where the different search algorithm is required. For example, 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 an external header from another project. +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 and to use the angle bracket form everywhere else, where possible. This encourages being clear about the locality of the header relative to files that include it, or scenarios where the different search algorithm is required. For example, 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 an external header from another project. ##### Example // foo.cpp: @@ -19200,7 +19200,7 @@ Nevertheless, the guidance is to use the quoted form for including files that ex #include "foo_utils/utils.h" // A file locally relative to foo.cpp, 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. For example, in a typical case where the '#include ""' search algorithm may 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. +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 may 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. Library creators should put their headers in a folder and have clients include those files using the relative path `#include `