Reputation: 3640
I am new to V8. I was trying to run the Hello World example form here.
But, I am getting compilation error at this line:
v8::String source = v8::String::New("'Hello' + ', World'");
error C2440: 'initializing' : cannot convert from 'v8::Local<v8::String>' to 'v8::String'
Why am I getting this error?
Upvotes: 1
Views: 2370
Reputation: 9983
The String class changed. It does not have anymore the New method; it has NewFrom* methods:
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)
You can browse the doxygen documentation: http://bespin.cz/~ondras/html/classv8_1_1String.html#aa4b8c052f5108ca6350c45922602b9d4
A string can be created this way:
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();
Upvotes: 3