簡體   English   中英

為什么在運行Boost代碼時總是收到警告?

[英]Why am I always getting warnings when running Boost code?

我注意到從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時我可能做錯了什么嗎?

可能這意味着編譯器已實施了更嚴格的警告。

如果支持您的編譯器版本/平台,上游通常會為這些編譯器修復代碼。

您通常可以通過執行以下操作來隱藏系統標題的警告

-isystem /path/to/boost

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

不只是你 其他人也報告了此問題。 您的代碼雖然很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM