mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
doc: Tidy up shadowing section
This commit is contained in:
parent
fe001925f8
commit
9452802480
1 changed files with 2 additions and 16 deletions
|
@ -27,7 +27,7 @@ Developer Notes
|
||||||
- [General C++](#general-c)
|
- [General C++](#general-c)
|
||||||
- [C++ data structures](#c-data-structures)
|
- [C++ data structures](#c-data-structures)
|
||||||
- [Strings and formatting](#strings-and-formatting)
|
- [Strings and formatting](#strings-and-formatting)
|
||||||
- [Variable names](#variable-names)
|
- [Shadowing](#shadowing)
|
||||||
- [Threads and synchronization](#threads-and-synchronization)
|
- [Threads and synchronization](#threads-and-synchronization)
|
||||||
- [Scripts](#scripts)
|
- [Scripts](#scripts)
|
||||||
- [Shebang](#shebang)
|
- [Shebang](#shebang)
|
||||||
|
@ -611,27 +611,13 @@ Strings and formatting
|
||||||
|
|
||||||
- *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion
|
- *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 rising
|
Although the shadowing warning (`-Wshadow`) is not enabled by default (it prevents issues rising
|
||||||
from using a different variable with the same name),
|
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.
|
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
|
When using nested cycles, do not name the inner cycle variable the same as in
|
||||||
upper cycle etc.
|
upper cycle etc.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue