user2030677
user2030677

Reputation: 3526

Why am I always getting warnings when running Boost code?

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?

Upvotes: 2

Views: 176

Answers (2)

sehe
sehe

Reputation: 392911

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)

Upvotes: 2

user142650
user142650

Reputation:

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

Upvotes: 1

Related Questions