Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#3465 closed Bugs (wontfix)

MSVC fails to compile intrusive when in DLL interface

Reported by: wim@… Owned by: Ion Gaztañaga
Milestone: Boost 1.41.0 Component: intrusive
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

This program:

#include <boost/intrusive/list.hpp> class declspec(dllexport) A : public boost::intrusive::list_base_hook<> { };

Yields this error on MSVC 2005 (similar on MSVC 2008), when compiling to a DLL:

1>C:\...\boost/intrusive/detail/generic_hook.hpp(191) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1> C:\...\boost/intrusive/detail/generic_hook.hpp(190) : while compiling class template member function 'void boost::intrusive::detail::generic_hook<GetNodeAlgorithms,Tag,LinkMode,HookType>::unlink(void)' 1> with 1> [ 1> GetNodeAlgorithms=boost::intrusive::get_list_node_algo<void *>, 1> Tag=boost::intrusive::default_tag, 1> LinkMode=safe_link, 1> HookType=1 1> ] 1> C:\...\boost/intrusive/list_hook.hpp(94) : see reference to class template instantiation 'boost::intrusive::detail::generic_hook<GetNodeAlgorithms,Tag,LinkMode,HookType>' being compiled 1> with 1> [ 1> GetNodeAlgorithms=boost::intrusive::get_list_node_algo<void *>, 1> Tag=boost::intrusive::default_tag, 1> LinkMode=safe_link, 1> HookType=1 1> ] 1> .\main.cpp(5) : see reference to class template instantiation 'boost::intrusive::list_base_hook<>' being compiled

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.

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>C:\...\boost/intrusive/list.hpp(125) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>', which is a similar problem.

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) && defined(wt_EXPORTS) namespace boost {

template<bool x> struct STATIC_ASSERTION_FAILURE { enum { value = 1 }; };

} #endif

Change History (3)

comment:1 by Ion Gaztañaga, 12 years ago

Resolution: wontfix
Status: newclosed

comment:2 by wim@…, 12 years ago

Version: Boost 1.40.0Boost 1.44.0

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:

1>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 )

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.

comment:3 by t.vierjahn@…, 11 years ago

We ran into the same problem and were able to fix it by using member hooks instead of base hooks for the list elements.

Note: See TracTickets for help on using tickets.