当我从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]为什么会发生这种情况?我在安装助推器时可能做错了什么吗?
发布于 2014-05-24 01:41:35
不仅仅是你。其他人也对这一问题进行了已报告。不过,您的代码很好。
发布于 2014-05-24 08:27:02
这很可能只是意味着编译器实现了更严格的警告。
如果支持编译器版本/平台,上游将(通常)修复这些编译器的代码。
您通常可以通过执行以下操作来隐藏系统标头的警告。
-isystem /path/to/boost(即代替-I /path/to/boost)
https://stackoverflow.com/questions/23840452
复制相似问题