[Boost-bugs] [Boost C++ Libraries] #3465: MSVC fails to compile intrusive when in DLL interface

Subject: [Boost-bugs] [Boost C++ Libraries] #3465: MSVC fails to compile intrusive when in DLL interface
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-18 12:52:34


#3465: MSVC fails to compile intrusive when in DLL interface
--------------------------+-------------------------------------------------
 Reporter: wim@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: intrusive
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 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

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3465>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC