为什么我在运行Boost代码时总是收到警告?
问题描述:
我注意到当我从Boost网站运行代码示例时,我收到了很多警告。例如,这个程序:为什么我在运行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
)
你知道教程在哪里可以找到并了解这些很酷的编译器选项? – user2030677
不幸的是。不,这只是累积的知识。有[this](http://stackoverflow.com/questions/568668/whats-your-favorite-g-option)虽然 – sehe
好的,谢谢! :) – user2030677