增强 MSVC 11 中的"destructor is not virtual"错误

Boost "destructor is not virtual" error in MSVC 11

本文关键字:not virtual 错误 is destructor 中的 增强 MSVC      更新时间:2023-10-16

我正试图使用MSVC 11.0编译一个带有boost 1.57.0的程序,但我得到了以下错误:

z:ddevboost_1_57_0boostexceptionexception.hpp(171) : error C4265: 'boost::exception_detail::error_info_container' but destructor is not virtual instances of this class may not be destructed correctly

我能做些什么吗?

这些帖子似乎没有提供解决方案

  • http://boost.2283326.n4.nabble.com/boost-exception-detail-error-info-base-does-not-have-virtual-destructor-td3384903.html
  • http://boost.2283326.n4.nabble.com/Re-exception-warning-about-non-virtual-destructor-resolution-td4554753.html

我以前应该考虑过这个问题。该错误是通过/W4升级为错误的警告。我设法通过在include周围包装一个警告禁用来修复它。

#pragma warning(push)
#pragma warning(disable : 4265)
#include <boost/...>
#pragma warning(pop)