This commit is contained in:
Gabriel Dos Reis 2017-05-08 10:50:03 -07:00
parent ad6f863152
commit 52aa9ba997

View File

@ -17298,18 +17298,29 @@ Flag `using namespace` at global scope in a header file.
To avoid files being `#include`d several times.
In order to avoid include guard collisions, do not just name the guard after the filename.
Be sure to also include a key and good differentiator, such as the name of library or component
the header file is part of.
##### Example
// file foobar.h:
#ifndef FOOBAR_H
#define FOOBAR_H
#ifndef LIBRARY_FOOBAR_H
#define LIBRARY_FOOBAR_H
// ... declarations ...
#endif // FOOBAR_H
#endif // LIBRARY_FOOBAR_H
##### Enforcement
Flag `.h` files without `#include` guards.
##### Note
Some implementations offer vendor extensions like `#pragma once` as alternative to include guards.
It is not standard and it is not portable. It injects the hosting machine's filesystem semantics
into your program, in addition to locking you down to a vendor.
Our recommendation is to write in ISO C++: See [rule P.2]((#Rp-Cplusplus).
### <a name="Rs-cycles"></a>SF.9: Avoid cyclic dependencies among source files
##### Reason