Merge #16461: doc: Tidy up shadowing section
9452802480
doc: Tidy up shadowing section (João Barbosa) Pull request description: Removes the example because it violates the code format. ACKs for top commit: MarcoFalke: unsigned ACK9452802480
ryanofsky: ACK9452802480
fanquake: ACK9452802480
- Thanks for following up. Tree-SHA512: 1fc31355d368225713298da7803e39e99014fbfcd229f2d3b56c082de95ab2965e51c80b172a5abce4646c53f845fa62a6d94d5df714e7835cac07a8ec7d5da7
This commit is contained in:
commit
085fe76299
1 changed files with 2 additions and 16 deletions
|
@ -27,7 +27,7 @@ Developer Notes
|
|||
- [General C++](#general-c)
|
||||
- [C++ data structures](#c-data-structures)
|
||||
- [Strings and formatting](#strings-and-formatting)
|
||||
- [Variable names](#variable-names)
|
||||
- [Shadowing](#shadowing)
|
||||
- [Threads and synchronization](#threads-and-synchronization)
|
||||
- [Scripts](#scripts)
|
||||
- [Shebang](#shebang)
|
||||
|
@ -613,27 +613,13 @@ Strings and formatting
|
|||
|
||||
- *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion.
|
||||
|
||||
Variable names
|
||||
Shadowing
|
||||
--------------
|
||||
|
||||
Although the shadowing warning (`-Wshadow`) is not enabled by default (it prevents issues arising
|
||||
from using a different variable with the same name),
|
||||
please name variables so that their names do not shadow variables defined in the source code.
|
||||
|
||||
E.g. in member initializers, prepend `_` to the argument name shadowing the
|
||||
member name:
|
||||
|
||||
```c++
|
||||
class AddressBookPage
|
||||
{
|
||||
Mode m_mode;
|
||||
}
|
||||
|
||||
AddressBookPage::AddressBookPage(Mode _mode)
|
||||
: m_mode(_mode)
|
||||
...
|
||||
```
|
||||
|
||||
When using nested cycles, do not name the inner cycle variable the same as in
|
||||
the upper cycle, etc.
|
||||
|
||||
|
|
Loading…
Reference in a new issue