diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-09 14:12:07 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-09 14:12:19 +0100 |
commit | e0477f6d20726d958685e44ea33f448a0c3ae15c (patch) | |
tree | 3a1e71dfe026648ee1a4e6add1b6bef3807fd5d4 /doc | |
parent | e81df49644c21f835e25028ab4643aa9bf5ae8da (diff) | |
parent | 359bac7cff235f60c8f5abb66a861c5a7b9a2b6d (diff) |
Merge #8794: Enable -Wshadow by default
359bac7 Add notes about variable names and shadowing (Pavel Janík)
fd5654c Check and enable -Wshadow by default. (Pavel Janík)
Diffstat (limited to 'doc')
-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 70c0690ba3..b0794e6d30 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 ---------------------------- |