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.