I lately decided to include the JavaScript V8 Engine in my project. After compiling and linking to it, I wanted to run the example from the Getting Started guide.
It works in general, but for some reasons there are namespace conflicts when I do not specify the v8
namespace in front of each class name. Visual Studio 2012 tells me for example, that the name Context
would be ambiguous. But I do not understand why.
The only namespaces I include in this file are std
and v8
. It is a header file and before you ask, it's meant to be so since it claims to be a header-only library.
#pragma once
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <memory>
#include <typeindex>
#include <iostream>
#include <fstream>
#include <V8/v8.h>
namespace library_name
{
using namespace std;
using namespace v8;
// here comes the example code and more...
}
To find out where a symbol with the name Context
might be defined too, I used the Find Definition
command in Visual Studio, available in the context menu. This is the list of results.
It lists for example sf::Context
which I use in the project but not in that header. There are also definitions in cryptic namespaces located at files in a directory named Windows Kits
. I neither know what they are for nor have I included them intentionally. I don't include other header files except from the standard library and JavaScript V8 as shown above.
Why do the Context
s from different namespaces collides with each other? How can I fix this collisions to use the v8
namespace?