首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在运行Boost代码时总是收到警告?

为什么在运行Boost代码时总是收到警告?
EN

Stack Overflow用户
提问于 2014-05-24 01:33:59
回答 2查看 134关注 0票数 2

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

代码语言:javascript
复制
#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;
}

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

代码语言:javascript
复制
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]

为什么会发生这种情况?我在安装助推器时可能做错了什么吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-24 01:41:35

不仅仅是你。其他人也对这一问题进行了已报告。不过,您的代码很好。

票数 1
EN

Stack Overflow用户

发布于 2014-05-24 08:27:02

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

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

您通常可以通过执行以下操作来隐藏系统标头的警告。

代码语言:javascript
复制
-isystem /path/to/boost

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23840452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档