[英]V8 Hello World compilation error: cannot convert from 'v8::Local<v8::String>' to 'v8::String'
我是V8的新手。 我試圖在這里運行Hello World示例表單。
但是,我在這一行得到編譯錯誤:
v8::String source = v8::String::New("'Hello' + ', World'");
error C2440: 'initializing' : cannot convert from 'v8::Local<v8::String>' to 'v8::String'
為什么我收到此錯誤?
String類已更改。 它不再具有New方法; 它有NewFrom *方法:
static Local< String > NewFromUtf8 (Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
static Local< String > NewFromOneByte (Isolate *isolate, const uint8_t *data, NewStringType type=kNormalString, int length=-1)
static Local< String > NewFromTwoByte (Isolate *isolate, const uint16_t *data, NewStringType type=kNormalString, int length=-1)
您可以瀏覽doxygen文檔: http : //bespin.cz/~ondras/html/classv8_1_1String.html#aa4b8c052f5108ca6350c45922602b9d4
可以通過以下方式創建字符串:
v8::Isolate* i = v8::Isolate::New();//create an isolate instance
//( if you already have one just get it: GetIsolate()
//=>http://bespin.cz/~ondras/html/classv8_1_1Context.html
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8(i,"asd");
i->Dispose();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.