How to find out how namespace got polluted?
Posted
by dehmann
on Stack Overflow
See other posts from Stack Overflow
or by dehmann
Published on 2010-04-08T18:28:36Z
Indexed on
2010/04/08
18:33 UTC
Read the original article
Hit count: 130
Consider the following little piece of code:
// all of these include other headers, lots of code:
#include "myheader1.h"
#include "myheader2.h"
#include <string>
void foo() {
string s("hello world"); // oh no, why does this compile??
}
This compiles, so obviously some of the recursively included header files has a
using namespace std;
somewhere. How would you go about finding out where that offending line of code is?
Just using grep
on all header files won't really work because that statement is often used inside a function, where it is safe and won't pollute the rest of the code.
© Stack Overflow or respective owner