gpt4 book ai didi

c++ - 为什么我在运行 Boost 代码时总是收到警告?

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

我注意到当我运行来自 Boost 网站的代码示例时收到大量警告。例如这个程序:

#include <cassert>
#include <string>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filtering_stream.hpp>

namespace io = boost::iostreams;

int main()
{
using namespace std;

string result;
io::filtering_ostream out(io::back_inserter(result));
out << "Hello World!";
out.flush();
std::cout << result;
}

这些是我收到的警告(我已经取出了大部分的血液和内脏):

warning: declaration of 'close' shadows a member of 'this' [-Wshadow]
warning: declaration of 'ptr' shadows a member of 'this' [-Wshadow]
warning: declaration of 'close' shadows a member of 'this' [-Wshadow]
warning: declaration of 'next' shadows a member of 'this' [-Wshadow]
warning: declaration of 'component_type' shadows a member of 'this' [-Wshadow]
warning: declaration of 'close' shadows a member of 'this' [-Wshadow]
warning: declaration of 'component_type' shadows a member of 'this' [-Wshadow]
warning: declaration of 'next' shadows a member of 'this' [-Wshadow]
warning: declaration of 'close' shadows a member of 'this' [-Wshadow]
warning: declaration of 'next' shadows a member of 'this' [-Wshadow]
warning: declaration of 'close' shadows a member of 'this' [-Wshadow]

为什么会这样?有没有可能我在安装 Boost 时做错了什么?

最佳答案

这可能只是意味着编译器实现了更严格的警告。

如果您的编译器版本/平台受支持,上游(通常)会修复这些编译器的代码。

您通常可以隐藏系统 header 的警告,例如

-isystem /path/to/boost

(即代替 -I/path/to/boost)

关于c++ - 为什么我在运行 Boost 代码时总是收到警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23840452/

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