Boost C++ Libraries: Ticket #3465: MSVC fails to compile intrusive when in DLL interface https://svn.boost.org/trac10/ticket/3465 <p> This program: </p> <p> #include &lt;boost/intrusive/list.hpp&gt; class <span class="underline">declspec(dllexport) A : public boost::intrusive::list_base_hook&lt;&gt; { }; </span></p> <p> Yields this error on MSVC 2005 (similar on MSVC 2008), when compiling to a DLL: </p> <p> 1&gt;C:\...\boost/intrusive/detail/generic_hook.hpp(191) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE&lt;x&gt;' 1&gt; with 1&gt; [ 1&gt; x=false 1&gt; ] 1&gt; C:\...\boost/intrusive/detail/generic_hook.hpp(190) : while compiling class template member function 'void boost::intrusive::detail::generic_hook&lt;<a class="missing wiki">GetNodeAlgorithms</a>,Tag,<a class="missing wiki">LinkMode</a>,<a class="missing wiki">HookType</a>&gt;::unlink(void)' 1&gt; with 1&gt; [ 1&gt; <a class="missing wiki">GetNodeAlgorithms</a>=boost::intrusive::get_list_node_algo&lt;void *&gt;, 1&gt; Tag=boost::intrusive::default_tag, 1&gt; <a class="missing wiki">LinkMode</a>=safe_link, 1&gt; <a class="missing wiki">HookType</a>=1 1&gt; ] 1&gt; C:\...\boost/intrusive/list_hook.hpp(94) : see reference to class template instantiation 'boost::intrusive::detail::generic_hook&lt;<a class="missing wiki">GetNodeAlgorithms</a>,Tag,<a class="missing wiki">LinkMode</a>,<a class="missing wiki">HookType</a>&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; <a class="missing wiki">GetNodeAlgorithms</a>=boost::intrusive::get_list_node_algo&lt;void *&gt;, 1&gt; Tag=boost::intrusive::default_tag, 1&gt; <a class="missing wiki">LinkMode</a>=safe_link, 1&gt; <a class="missing wiki">HookType</a>=1 1&gt; ] 1&gt; .\main.cpp(5) : see reference to class template instantiation 'boost::intrusive::list_base_hook&lt;&gt;' being compiled </p> <p> If the dllexport is removed, the program compiles fine. When the unlink() method is commented out in generic_hook.hpp, the program compiles fine. We discovered this because our library compiles as a static library, but not as a DLL. </p> <p> I wanted to work around this by using auto_unlink hooks instead of safe_link hooks, but then I get this error when I create a list: 1&gt;C:\...\boost/intrusive/list.hpp(125) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE&lt;x&gt;', which is a similar problem. </p> <p> I could not find a clean way to disable static assertions, or another workaround to allow compilation without modifications to boost. Any suggestions? I currently resorted to adding this hack in files that include intrusive headers: #if defined(WIN32) &amp;&amp; defined(wt_EXPORTS) namespace boost { </p> <blockquote> <p> template&lt;bool x&gt; struct STATIC_ASSERTION_FAILURE { enum { value = 1 }; }; </p> </blockquote> <p> } #endif </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3465 Trac 1.4.3 Ion Gaztañaga Thu, 26 Aug 2010 11:33:36 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3465#comment:1 https://svn.boost.org/trac10/ticket/3465#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">wontfix</span> </li> </ul> <p> I could not get a solution for this, maybe related to </p> <p> <a class="ext-link" href="http://lists.boost.org/boost-users/2005/11/14932.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2005/11/14932.php</a> </p> <p> <a class="ext-link" href="http://permalink.gmane.org/gmane.comp.lib.boost.user/14382"><span class="icon">​</span>http://permalink.gmane.org/gmane.comp.lib.boost.user/14382</a> </p> Ticket wim@… Fri, 29 Oct 2010 14:49:26 GMT version changed https://svn.boost.org/trac10/ticket/3465#comment:2 https://svn.boost.org/trac10/ticket/3465#comment:2 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.44.0</span> </li> </ul> <p> This got worse with boost 1.44.0 on MSVC 2010. I assume that BOOST_STATIC_ASSERT now uses a C++0x static assert, and the workaround mentioned in the original submission (which basically disables BOOST_STATIC_ASSERT) no longer works. The compiler now complains: </p> <p> 1&gt;C:\Program Files\boost\boost_1_44\boost/intrusive/detail/generic_hook.hpp(191): error C2338: ( (int)boost_intrusive_tags::link_mode == (int)auto_unlink ) </p> <p> May I suggest to disable the BOOST_STATIC_ASSERT when compiling on MSVC? My only workaround now is not to use boost_intrusive when building a DLL. </p> Ticket t.vierjahn@… Tue, 08 Nov 2011 12:55:05 GMT <link>https://svn.boost.org/trac10/ticket/3465#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3465#comment:3</guid> <description> <p> We ran into the same problem and were able to fix it by using <a href="http://www.boost.org/doc/libs/1_47_0/doc/html/intrusive/usage.html#intrusive.usage.usage_member_hook">member hooks</a> instead of base hooks for the list elements. </p> </description> <category>Ticket</category> </item> </channel> </rss>