gpt4 book ai didi

c++ - MinGW 5.1.0 似乎不再抑制警告

转载 作者:行者123 更新时间:2023-11-30 05:41:43 28 4
gpt4 key购买 nike

我正在运行 Windows 7.1 64 位、Boost 1.58.0 和(最近)MinGW 5.1.0 64 位。

之前在运行MinGW 4.9.2的时候,我使用了下面的

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include "boost/asio/ip/host_name.hpp" // for host_name()
#pragma GCC diagnostic pop

以抑制不必要的警告,而且它在大多数情况下都有效。如果代码中存在合法错误,这些被抑制的警告无论如何都会出现——但我可以接受。

昨天,我升级到 MinGW 5.1.0 64 位。上面显示的编译指示似乎不再抑制警告。我在 Google 上找不到任何可以表明发生任何变化的信息。

我真的很想让这个功能再次工作,因为我使用的 Boost Test 有很多“std::auto_ptr is deprecated”警告。

最佳答案

查看错误:

In file included from C:/C++/MinGW-w64/5.1.0/i686-w64-mingw32/include/c++/memory:81:0,
from ../common/include/boost/asio/detail/addressof.hpp:21,
from ../common/include/boost/asio/detail/handler_alloc_helpers.hpp:19,
from ../common/include/boost/asio/detail/bind_handler.hpp:19,
from ../common/include/boost/asio/detail/wrapped_handler.hpp:18,
from ../common/include/boost/asio/io_service.hpp:24,
[...]:
boost/smart_ptr/shared_ptr.hpp:549:38: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
^

您可以看到编译器标志不再是 -Wunused-variable,而是现在的 -Wdeprecated-declarations。在 #pragma 中反射(reflect)这一点使它再次为我工作。

关于c++ - MinGW 5.1.0 似乎不再抑制警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31037944/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com