mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
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)
This commit is contained in:
commit
e0477f6d20
@ -203,6 +203,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
|
|||||||
AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-Wshadow],[CXXFLAGS="$CXXFLAGS -Wshadow"],,[[$CXXFLAG_WERROR]])
|
||||||
|
|
||||||
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
|
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
|
||||||
## unknown options if any other warning is produced. Test the -Wfoo case, and
|
## unknown options if any other warning is produced. Test the -Wfoo case, and
|
||||||
|
@ -331,6 +331,32 @@ 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
|
||||||
|
--------------
|
||||||
|
|
||||||
|
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
|
Threads and synchronization
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user