diff options
| author | Pavel JanÃk <[email protected]> | 2016-09-22 16:39:25 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-11-09 14:11:24 +0100 |
| commit | 359bac7cff235f60c8f5abb66a861c5a7b9a2b6d (patch) | |
| tree | 5dda4966ae84fb30ec78c1dd77383542d8c1436c /doc/developer-notes.md | |
| parent | Check and enable -Wshadow by default. (diff) | |
| download | discoin-359bac7cff235f60c8f5abb66a861c5a7b9a2b6d.tar.xz discoin-359bac7cff235f60c8f5abb66a861c5a7b9a2b6d.zip | |
Add notes about variable names and shadowing
Diffstat (limited to 'doc/developer-notes.md')
| -rw-r--r-- | doc/developer-notes.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 70c0690ba..b0794e6d3 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -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 ---------------------------- |