J
Juha Nieminen
A relatively large open source C++ project suffered of a sudden problem
when trying to compile the program on Visual Studio 2010: The program
wouldn't compile because there were ambiguous definitions of 'shared_ptr'.
As you might guess, this project uses the boost library and liberally
uses "using namespace std;" and "using namespace boost;" everywhere, and it
so happens that VS2010 has an implementation of std::shared_ptr of the
upcoming C++ standard.
In principle it's completely ok if two libraries use the same name for
something, as long as they do it inside their respective namespaces. After
all, that's exactly what namespaces exist for in the first place. Naturally
because of this any decent C++ book/tutorial warns about the dangers of
writing 'using namespace', as it may produce naming conflicts.
Well, here's an *actual* concrete example which happened in practice.
when trying to compile the program on Visual Studio 2010: The program
wouldn't compile because there were ambiguous definitions of 'shared_ptr'.
As you might guess, this project uses the boost library and liberally
uses "using namespace std;" and "using namespace boost;" everywhere, and it
so happens that VS2010 has an implementation of std::shared_ptr of the
upcoming C++ standard.
In principle it's completely ok if two libraries use the same name for
something, as long as they do it inside their respective namespaces. After
all, that's exactly what namespaces exist for in the first place. Naturally
because of this any decent C++ book/tutorial warns about the dangers of
writing 'using namespace', as it may produce naming conflicts.
Well, here's an *actual* concrete example which happened in practice.