2

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?

user2030677
  • 3,448
  • 4
  • 23
  • 36

2 Answers2

2

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 e.g.

-isystem /path/to/boost

(i.e. instead of -I /path/to/boost)

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Do you know tutorials where I can find and learn about these cool compiler options? – user2030677 May 25 '14 at 18:44
  • Sadly. No. It's just accrued knowledge. There's [this](http://stackoverflow.com/questions/568668/whats-your-favorite-g-option) though – sehe May 25 '14 at 18:45
1

It's not just you. Others have also reported this issue. Your code is fine though.