I notice that I am getting a ton of warnings when I run code examples from the Boost website. For example, this program:
#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;
}
These are the warnings I get (I've taken out most of the blood and guts):
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]
Why is this happening? Could it be possible that I did something wrong while installing Boost?
Likely this just means the compiler has implemented more stringent warnings.
Upstream will (usually) fix the code for these compilers if your compiler version/platform is supported.
You can usually hide warnings for system headers by doing eg
-isystem /path/to/boost
(ie instead of -I /path/to/boost
)
It's not just you. Others have also reported this issue. Your code is fine though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.