lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] [low priority] How to deal with variable shadowing warnings?


From: Vadim Zeitlin
Subject: [lmi] [low priority] How to deal with variable shadowing warnings?
Date: Mon, 8 Feb 2016 01:54:54 +0100

 Hello,

 The latest version of MSVC compiler (MSVS 2015 a.k.a. VC 14) enables the
warnings about variables hiding other names in the same scope by default
which results in the following warnings (the line numbers are slightly
different from the mainline as this is from my local branch):

census_view.cpp(1530): warning C4456: declaration of 'oss' hides previous local 
declaration
         census_view.cpp(1501): note: see declaration of 'oss'
census_view.cpp(1536): warning C4456: declaration of 'oss' hides previous local 
declaration
         census_view.cpp(1501): note: see declaration of 'oss'
dbdict.cpp(1114): warning C4456: declaration of 'i' hides previous local 
declaration
         dbdict.cpp(1093): note: see declaration of 'i'
group_values.cpp(366): warning C4456: declaration of 'meter' hides previous 
local declaration
         group_values.cpp(249): note: see declaration of 'meter'
ihs_acctval.cpp(1205): warning C4458: declaration of 'mode' hides class member
         account_value.hpp(463): note: see declaration of 'AccountValue::mode' 
(compiling source file ihs_acctval.cpp)
ihs_avmly.cpp(701): warning C4458: declaration of 'mode' hides class member
         account_value.hpp(463): note: see declaration of 'AccountValue::mode' 
(compiling source file ihs_avmly.cpp)
ledger_xml_io.cpp(764): warning C4456: declaration of 'suffix' hides previous 
local declaration
         ledger_xml_io.cpp(726): note: see declaration of 'suffix'
ledger_xml_io.cpp(948): warning C4456: declaration of 'i' hides previous local 
declaration
         ledger_xml_io.cpp(761): note: see declaration of 'i'
xml_lmi.cpp(245): warning C4456: declaration of 'i' hides previous local 
declaration
         xml_lmi.cpp(244): note: see declaration of 'i'

 I'd like to fix them if you don't object because I think it's preferable
to disabling them, especially for the warning about hiding the class member
which is more error prone than the one about hiding another local variable.
Would you accept patches fixing these warnings? And, if so, what would be
your preferred way of doing this, especially for the common variable names
such as "i"? Should I use "i2", "j" or sacrifice brevity and use more
descriptive names for both the hiding and the hidden variable?

 Thanks,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]