Boost C++ Libraries: Ticket #3729: boost.log and 1.41.0 : external linkage error https://svn.boost.org/trac10/ticket/3729 <p> compilation of boost.log (<a class="ext-link" href="http://boost-log.sourceforge.net"><span class="icon">​</span>http://boost-log.sourceforge.net</a>) within boost 1.41 on Mac OSX 10.5 and gcc 4.2.1 fails due to an "external linkage" error: </p> <p> ./boost/intrusive/detail/is_stateful_value_traits.hpp:38: error: ‘&amp; boost::intrusive::derivation_value_traits&lt;T, <a class="missing wiki">NodeTraits</a>, <a class="missing wiki">LinkMode</a>&gt;::to_node_ptr [with T = boost::log_mt_posix::basic_attribute_set&lt;char&gt;::implementation::node, <a class="missing wiki">NodeTraits</a> = boost::log_mt_posix::&lt;unnamed&gt;::ordered_list&lt;boost::log_mt_posix::basic_attribute_set&lt;char&gt;::implementation::node, boost::log_mt_posix::basic_attribute_set&lt;char&gt;::node_base&gt;::node_traits, boost::intrusive::link_mode_type <a class="missing wiki">LinkMode</a> = safe_link]’ is not a valid template argument for type ‘boost::log_mt_posix::basic_attribute_set&lt;char&gt;::node_base* (*)(boost::log_mt_posix::basic_attribute_set&lt;char&gt;::implementation::node&amp;)’ because function ‘static typename NodeTraits::node_ptr boost::intrusive::derivation_value_traits&lt;T, <a class="missing wiki">NodeTraits</a>, <a class="missing wiki">LinkMode</a>&gt;::to_node_ptr(typename std::iterator_traits&lt;typename boost::pointer_to_other&lt;typename NodeTraits::node_ptr, T&gt;::type&gt;::reference) [with T = boost::log_mt_posix::basic_attribute_set&lt;char&gt;::implementation::node, <a class="missing wiki">NodeTraits</a> = boost::log_mt_posix::&lt;unnamed&gt;::ordered_list&lt;boost::log_mt_posix::basic_attribute_set&lt;char&gt;::implementation::node, boost::log_mt_posix::basic_attribute_set&lt;char&gt;::node_base&gt;::node_traits, boost::intrusive::link_mode_type <a class="missing wiki">LinkMode</a> = safe_link]’ has not external linkage </p> <blockquote> <p> "g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -dynamic -no-cpp-precomp -gdwarf-2 -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_DATE_TIME_DYN_LINK=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_LOG_BUILDING_THE_LIB=1 -DBOOST_LOG_DLL -DBOOST_LOG_USE_CHAR -DBOOST_LOG_USE_NATIVE_SYSLOG=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_DLL=1 -DDATE_TIME_INLINE -DNDEBUG -I"." -c -o "bin.v2/libs/log/build/darwin-4.2.1/release/threading-multi/attribute_set.o" "libs/log/src/attribute_set.cpp" </p> </blockquote> <p> I had reported the problem to the boost.log maintaner before to open the ticket and the response was: </p> <pre class="wiki">Looks like a compiler bug to me since the derivation_value_traits::to_value_ptr clearly has external linkage. You should report the problem to Boost.Intrusive maintainer. I'm not sure I can work it around on Boost.Log side. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3729 Trac 1.4.3 Andrey Semashev Fri, 29 Jan 2010 19:19:06 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3729#comment:1 https://svn.boost.org/trac10/ticket/3729#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> From the Boost developers ML: </p> <blockquote class="citation"> <p> The combination of gcc version (gcc 4.2.x), the reported error reason (has not external linkage) and the type in the error location including names in an anonymous namespace (occurrences of&lt;unnamed&gt;) lead me to believe this is the same as a problem I've encountered a number of times, most recently yesterday. </p> <p> The issue seems to be that gcc 4.2 contains (the beginnings of?) an optimization to exclude symbols from anonymous namespaces from the set of external linker symbols, as a space optimization, and possibly with other benefits. Unfortunately, in gcc 4.2 this seems to have been somewhat botched because these symbols still need to be treated as having external linkage as far as various C++ language features are concerned, and that doesn't appear to be done correctly. These problems seem to have been addressed in gcc 4.3. </p> <p> The only workaround I've found for this is to change the relevant anonymous namespace to be a named namespace, typically some "detail" or "impl" type of namespace since these aren't supposed to be public names. I've only encountered this problem with gcc 4.2.x; 4.1 doesn't have the (attempt at) the relevant optimization, and this problem seems to have been fixed in gcc 4.3. </p> </blockquote> <p> -- Kim Barrett </p> Ticket