Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add notes about variable names and shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanik authored and laanwj committed Nov 9, 2016
1 parent fd5654c commit 359bac7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------
Expand Down

0 comments on commit 359bac7

Please sign in to comment.