无法抑制GCC -Wextra警告

时间:2014-08-05 14:38:10

标签: c++ gcc suppress-warnings gcc-warning g++4.8

我在我的一个项目中使用Boost.Log v2,当我构建它时会收到以下警告:

C:\boost-1.55\include\boost\log\utility\setup\common_attributes.hpp:22: In file included from C:\boost-1.55\include/boost/log/utility/setup/common_attributes.hpp:22:0,
PROJECT_PATH\PROJECT_NAME\main.cpp:12: from ..\PROJECT_NAME\main.cpp:12:
C:\boost-1.55\include\boost\log\attributes\counter.hpp:-1: In instantiation of 'boost::log::v2_mt_nt5::attribute_value boost::log::v2_mt_nt5::attributes::counter<T>::impl_generic::get_value() [with T = unsigned int]':
PROJECT_PATH\PROJECT_NAME\main.cpp:44: required from here
C:\boost-1.55\include\boost\log\attributes\counter.hpp:133: avertissement : address requested for 'next', which is declared 'register' [-Wextra]
     return make_attribute_value(next);
                                     ^

我想删除此警告,因为我无法解决此问题,因为它是Boost库的一部分。但是,我没有找到任何-Wno-xxx选项来删除它(-Wno-extra不起作用)。我使用的是GCC 4.8.2。

如何取消此警告?

1 个答案:

答案 0 :(得分:4)

您可以在包含升级库

时禁用警告
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wextra" // address requested for 'next', which is declared 'register'

//#include "boost/header_you_want.h"

#pragma GCC diagnostic pop