Browse Source

Add notes about variable names and shadowing

pull/1/head
Pavel Janík 6 years ago committed by Wladimir J. van der Laan
parent
commit
359bac7cff
  1. 26
      doc/developer-notes.md

26
doc/developer-notes.md

@ -331,6 +331,32 @@ Strings and formatting @@ -331,6 +331,32 @@ Strings and formatting
- *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion
Variable names
--------------
The shadowing warning (`-Wshadow`) is enabled by default. It prevents issues rising
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 mode;
}
AddressBookPage::AddressBookPage(Mode _mode) :
mode(_mode)
...
```
When using nested cycles, do not name the inner cycle variable the same as in
upper cycle etc.
Threads and synchronization
----------------------------

Loading…
Cancel
Save