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 ACK 9452802480
  ryanofsky:
    ACK 9452802480
  fanquake:
    ACK 9452802480 - Thanks for following up.

Tree-SHA512: 1fc31355d368225713298da7803e39e99014fbfcd229f2d3b56c082de95ab2965e51c80b172a5abce4646c53f845fa62a6d94d5df714e7835cac07a8ec7d5da7
This commit is contained in:
fanquake 2019-08-29 08:13:07 +08:00
commit 085fe76299
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -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.