My code is including headers from some large open source projects. One of them is C and the other C++. Unfortunately, the C header declares structures that share the same name as C++ standard template library (std::) classes like map
and list
. I'm getting an "ambiguous symbol" error on those. It turns out that the C++ project has using namespace std;
in some header files. I don't want to fork the packages and modify them if I can avoid it, as it would be a monumental task.
Is it possible instead to "turn off" the using namespace std
inside my code, so it will not attempt to resolve list
or map
as possibly belonging to that namespace? See the code sample below and the needed not_using
directive. I know not_using
doesn't exist. I'm looking for a way to achieve that effect.
using namespace std;
map<string, string> mapOk; // compiles but conflicts with C symbol
not_using namespace std; // I need something like this because...
std::map<std::string, std::string> mapOk2; // I want to force the use of std:: to resolve
map<string, string> badMap; // Causes compile error