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

标签 c++ gcc mingw gcc-warning

我正在运行 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/

相关文章:

c++ - 赋值运算符

c++ - 如果我针对大小而不是速度进行优化,为什么 GCC 生成的代码速度会快 15-20%?

c++ - 如何在 Clion 中链接 ws2_32

c++ - 如何在 Eclipse C++ 中使用 -std-c++11

c++ - Mingw libgcc_s_sjlj-1.dll 丢失

c++ - 如何清除C++中的输入流?

c++ - 为什么在重定向 stdout 和 stdin 时 Python 的行为不符合预期?

c++ - 纯虚最终函数 : legal in C++11

c++ - 使用 Eigen3 实现 C++ 的最大精度

c - 释放树中动态分配的内存