Boost C++ Libraries: Ticket #3031: Boost::Accumulators: Shadow Variables and Unused Globals Cause Warnings/Errors When Headers Are Not in System Path https://svn.boost.org/trac10/ticket/3031 <p> I've recently added Boost to an Xcode 3.1.2 project with the following warnings enabled in GCC/G++ 4.0.1: </p> <blockquote> <p> -Werror -Wreturn-type -Wunused-function -Wunused-label -Wunused-variable -Wshadow </p> </blockquote> <p> Unfortunately, when boost is not installed in a "system" path--as is the case here--unused and shadow variable warnings cause the build to fail when warnings are treated as errors. This issue last came up for me about a year ago in 1_35_0 with filesystem.hpp: </p> <p> <a class="ext-link" href="http://article.gmane.org/gmane.comp.lib.boost.user/38297/match=shadow+variables+cause"><span class="icon">​</span>http://article.gmane.org/gmane.comp.lib.boost.user/38297/match=shadow+variables+cause</a> </p> <p> The included headers this time are: </p> <blockquote> <p> boost/accumulators/accumulators.hpp boost/accumulators/statistics/stats.hpp boost/accumulators/statistics/rolling_mean.hpp </p> </blockquote> <p> To test and fix, I isolated with: </p> <blockquote> <p> printf "#include &lt;${<a class="missing wiki">BoostHeader</a>}&gt;\nint main(void) { return 0; }" | /Developer/usr/bin/gcc-4.0 -x c++ -Wall -Wshadow -Werror -o test -I${<a class="missing wiki">BoostRoot</a>}/boost/include - </p> </blockquote> <p> The patch to address this is as follows and impacts the headers below: </p> <blockquote> <p> boost/accumulators/framework/accumulator_set.hpp boost/accumulators/framework/accumulators/droppable_accumulator.hpp boost/accumulators/statistics/rolling_mean.hpp boost/accumulators/statistics/rolling_window.hpp boost/accumulators/statistics_fwd.hpp </p> </blockquote> <p> Patches for other headers to be filed separately. Because this problem seems to come up frequently, perhaps there is a way -Wshadow and -Wall can be forced for all unit tests? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3031 Trac 1.4.3 gerickson@… Fri, 15 May 2009 03:52:29 GMT attachment set https://svn.boost.org/trac10/ticket/3031 https://svn.boost.org/trac10/ticket/3031 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-00.patch</span> </li> </ul> <p> Patch for Boost::Accumulators -Wshadow and -Wunused Errors </p> Ticket Eric Niebler Fri, 15 May 2009 21:41:31 GMT component changed; owner set https://svn.boost.org/trac10/ticket/3031#comment:1 https://svn.boost.org/trac10/ticket/3031#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Eric Niebler</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">accumulator</span> </li> </ul> Ticket Eric Niebler Mon, 20 Jul 2009 21:13:12 GMT status changed https://svn.boost.org/trac10/ticket/3031#comment:2 https://svn.boost.org/trac10/ticket/3031#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Eric Niebler Mon, 20 Jul 2009 23:05:00 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3031#comment:3 https://svn.boost.org/trac10/ticket/3031#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/55050" title="eliminate shadow warnings and unused variable warnings, fixes #3262, ...">[55050]</a>) eliminate shadow warnings and unused variable warnings, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3262" title="#3262: Bugs: Boost::Accumulators::Statistics: Unused Globals Cause Warnings/Errors ... (closed: fixed)">#3262</a>, fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3276" title="#3276: Bugs: Boost::Accumulators::Statistics: Unused Variables and Globals Cause ... (closed: fixed)">#3276</a>, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3031" title="#3031: Bugs: Boost::Accumulators: Shadow Variables and Unused Globals Cause ... (closed: fixed)">#3031</a> </p> Ticket