`boost``Signal2`库与Microsoft内存泄漏检测冲突?

时间:2015-12-04 15:02:54

标签: c++ boost memory-leaks

我有便携式Linux / Windows应用程序。我使用boost Signal2库来实现事件系统。

Microsoft在Visual C ++中具有内置内存泄漏检测功能。您必须在任何源文件的最开头包含一些代码,以用它们的调试版本替换普通mallocnew,并且这些调试内存管理函数会在应用程序退出时生成内存泄漏报告。代码如下:

#ifdef _DEBUG 
    #define _CRTDBG_MAP_ALLOC
    #include <stdlib.h>
    #include <crtdbg.h>  
    #ifndef DBG_NEW      
        #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )      
        #define new DBG_NEW   
    #endif
#endif

当我包含此代码时,程序停止编译。错误消息是不可理解的,甚至不指向发生错误的源文件(它们指向boost标题,但不指向我的程序头或代码文件)。错误报告如下:

D:\src\open-source\boost\boost/variant/detail/initializer.hpp(122): error C2061: syntax error : identifier 'dest'
1>          D:\src\open-source\boost\boost/variant/detail/initializer.hpp(116) : while compiling class template member function 'int boost::detail::variant::make_initializer_node::apply<T1,T2>::initializer_node::initialize(void *,boost::shared_ptr<void> &&)'
1>          with
1>          [
1>              T1=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>
1>  ,            T2=boost::mpl::l_iter<boost::mpl::list2<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr>>
1>          ]
1>          D:\src\open-source\boost\boost/variant/variant.hpp(1559) : see reference to function template instantiation 'int boost::detail::variant::make_initializer_node::apply<T1,T2>::initializer_node::initialize(void *,boost::shared_ptr<void> &&)' being compiled
1>          with
1>          [
1>              T1=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>
1>  ,            T2=boost::mpl::l_iter<boost::mpl::list2<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr>>
1>          ]
1>          D:\src\open-source\boost\boost/variant/detail/initializer.hpp(76) : see reference to class template instantiation 'boost::detail::variant::make_initializer_node::apply<T1,T2>::initializer_node' being compiled
1>          with
1>          [
1>              T1=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>
1>  ,            T2=boost::mpl::l_iter<boost::mpl::list2<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr>>
1>          ]
1>          D:\src\open-source\boost\boost/variant/variant.hpp(1339) : see reference to class template instantiation 'boost::detail::variant::make_initializer_node::apply<T1,T2>::initializer_node' being compiled
1>          with
1>          [
1>              T1=boost::mpl::pair<boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>,boost::mpl::l_iter<boost::mpl::list2<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr>>>::initializer_node,boost::mpl::int_<1>>
1>  ,            T2=boost::mpl::l_iter<boost::mpl::list1<boost::signals2::detail::foreign_void_shared_ptr>>
1>          ]
1>          D:\src\open-source\boost\boost/variant/variant.hpp(1555) : see reference to class template instantiation 'boost::variant<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>::initializer' being compiled
1>          D:\src\open-source\boost\boost/variant/variant.hpp(1732) : see reference to function template instantiation 'void boost::variant<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>::convert_construct<boost::shared_ptr<void>>(T &&,int,boost::mpl::false_)' being compiled
1>          with
1>          [
1>              T=boost::shared_ptr<void>
1>          ]
1>          D:\src\open-source\boost\boost/variant/variant.hpp(1732) : see reference to function template instantiation 'void boost::variant<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>::convert_construct<boost::shared_ptr<void>>(T &&,int,boost::mpl::false_)' being compiled
1>          with
1>          [
1>              T=boost::shared_ptr<void>
1>          ]
1>          D:\src\open-source\boost\boost/signals2/slot_base.hpp(49) : see reference to function template instantiation 'boost::variant<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>::variant<boost::shared_ptr<void>>(T &&,void *,void *)' being compiled
1>          with
1>          [
1>              T=boost::shared_ptr<void>
1>          ]
1>          D:\src\open-source\boost\boost/signals2/slot_base.hpp(49) : see reference to function template instantiation 'boost::variant<boost::shared_ptr<void>,boost::signals2::detail::foreign_void_shared_ptr,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>::variant<boost::shared_ptr<void>>(T &&,void *,void *)' being compiled
1>          with
1>          [
1>              T=boost::shared_ptr<void>
1>          ]

是否有任何解决方法可以使用boost并仍在Windows上使用内存泄漏检测?

0 个答案:

没有答案