Hello World and V8
Hello World and V8
我正在开发windows。我正在尝试使用undercorediscovery中的V8在V8中运行helloworld。这无法在行编译
// Get the default Isolate created at startup.
Isolate* isolate = Isolate::GetCurrent();
我查看了undercorediscovery标头,当这个类不在标头中时,它确实有旧的lib和标头。那很好。我删除了这条线路,用替换了前四条线路
// Create a stack-allocated handle scope.
HandleScope handle_scope;
// Create a new context.
Handle<Context> context = Context::New();
// Here's how you could create a Persistent handle to the context, if needed.
Persistent<Context> persistent_context(context);
它奏效了。所以这个隔离被添加到V8中。
然后我安装了node.js,它的deps文件夹中也有v8。我构建了node.js,v8也得到了构建。我遵循了nodejs插件开发的说明。它的"helloworld nodejs"是成功的。我认为实际的谷歌代码也应该像标题中的隔离类一样工作。但它并没有编译错误:
error C2664: 'v8::HandleScope::HandleScope(const v8::HandleSc
ope &)' : cannot convert parameter 1 from 'v8::Isolate *' to 'const v8::HandleS
cope &' [C:Usersasnegicompanynodejs projectnode-v0.10.15srcmy_filesbuil
dv8code.vcxproj]
Reason: cannot convert from 'v8::Isolate *' to 'const v8::HandleScope
'
No constructor could take the source type, or constructor overload re
solution was ambiguous
查看C:\Users\abc.node gyp\0.10.15\deps\v8\include\v8.h 的标题
它定义了类Isolate。此外,
template <class T> class Handle {
public:
/**
* Creates an empty handle.
*/
inline Handle() : val_(0) {}
/**
* Creates a new handle for the specified value.
*/
inline explicit Handle(T* val) : val_(val) {}
...........
...........
和
class HandleScope {
public:
inline HandleScope();
explicit inline HandleScope(Isolate* isolate);
.....
因此,谷歌的Hello世界的这一部分本应发挥作用:
// Get the default Isolate created at startup.
Isolate* isolate = Isolate::GetCurrent();
// Create a stack-allocated handle scope.
HandleScope handle_scope(isolate);
// Create a new context.
Handle<Context> context = Context::New(isolate);
问题出在哪里?
稳定节点v0.10.15使用Google V8版本3.14.5
(2012-10-22)C: \Documents\github\nodes\deps\v8\include\v8.h
class V8EXPORT HandleScope {
private:
HandleScope(const HandleScope&);
不稳定节点v0.11.5使用Google V8版本3.20.14
(2013-08-07)C: \Documents\github\nodes\deps\v8\include\v8.h
class V8_EXPORT HandleScope {
public:
// TODO(svenpanne) Deprecate me when Chrome is fixed!
HandleScope();
HandleScope(Isolate* isolate);
~HandleScope();
从节点\deps\v8\ChangeLog文件:
2013-03-15:版本3.17.11
添加了带有v8::Isolate的v8::HandleScope构造函数的版本参数,并使AdjustAmountOfExternalAllocatedMemory成为实例v8的方法:隔离。(第2487期)
指针与引用。看起来HandleScope()需要一个引用,而New()返回一个指针。
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- 为什么 Clang 不允许"and"作为函数名称?
- 位阵列上的快速AND运算
- 是否可以在 C++03 中定义'move-and-swap idiom'等效项
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- BoostPython and CMake
- 在 G++ v8.2.0 中使用 std::experimental::可选
- OpenSSL BIO and SSL_read
- Gurobi GRBModel and GRBmodel in C++
- 如何为 v8::P ersistent<v8::Function> 创建到 c++ 函数的包装器
- v8::HandleScope::CreateHandle() # 中的致命错误无法在没有 HandleScope 的情
- std::visit and std::variant usage
- SHBrowseForFolder with BIF_BROWSEFORCOMPUTER and SHGetPathFr
- 如何将节点 V8 字符串转换为 C++ 字符串
- Directx12 and keystrokes
- different between int **arr =new int [ n]; and int a[i][j]?
- C++ getenv and setenv
- v8::ObjectTemplate::SetAccessor and v8::Template::Set - Diff
- Hello World and V8