3

我正在尝试针对 Node 12 构建本机节点模块,但遇到以下错误:

warning: ‘static v8::Local<v8::String> v8::String::NewFromUtf8(v8::Isolate*, const char*, v8::String::NewStringType, int)’ is deprecated: Use maybe version [-Wdeprecated-declarations]

在代码上,例如:

v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "some string")

我理解错误,但基于 v8::String 文档,我无法弄清楚如何指定 Maybe 版本......原型看起来一样。如何使用此功能的 Maybe 版本?

4

1 回答 1

-1
size_t size = 100;
char *CharBuff = new char[size + 1];

v8::MaybeLocal<v8::String> result = v8::String::NewFromUtf8(
    isolate, CharBuff, v8::NewStringType::kNormal, static_cast<int>(size));
于 2019-04-25T05:14:43.330 回答