gpt4 book ai didi

c++ - 无法抑制 GCC -Wextra 警告

转载 作者:搜寻专家 更新时间:2023-10-31 01:03:49 28 4
gpt4 key购买 nike

我在我的一个项目中使用了 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。

我怎样才能抑制这个警告?

最佳答案

您可以在包含 boost 库时禁用警告

#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

关于c++ - 无法抑制 GCC -Wextra 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25141547/

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