Boost C++ Libraries: Ticket #9102: Various Boost header files define variables with internal linkage, which results in unnecessary code bloat https://svn.boost.org/trac10/ticket/9102 <p> Some Boost headers define variables with internal linkage. For example, in <code>boost/system/error_code.hpp</code>: </p> <pre class="wiki"> static const error_category &amp; posix_category = generic_category(); static const error_category &amp; errno_ecat = generic_category(); static const error_category &amp; native_ecat = system_category(); </pre><p> In <code>boost/asio/error.hpp</code>: </p> <pre class="wiki">static const boost::system::error_category&amp; system_category = boost::asio::error::get_system_category(); static const boost::system::error_category&amp; netdb_category = boost::asio::error::get_netdb_category(); static const boost::system::error_category&amp; addrinfo_category = boost::asio::error::get_addrinfo_category(); static const boost::system::error_category&amp; misc_category = boost::asio::error::get_misc_category(); </pre><p> Because of this, every translation unit that includes these headers results in a separate instance of each of these variables in the resulting executable file. Because these variables have non-constant initializers, not only they are not eliminated during linking, even if not used, but also each instance of such variable results in a call to a initialization function during program startup. </p> <p> I think that merely including a Boost header, without using anything from it, should not result in any extra code remaining in the resulting executable - especially not if each translation unit results in a separate copy of such code. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9102 Trac 1.4.3 viboes Tue, 17 Sep 2013 21:06:03 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9102#comment:1 https://svn.boost.org/trac10/ticket/9102#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Beman Dawes</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">system</span> </li> </ul> Ticket