如何解决使用v8时不推荐使用的警告
我正在使用node-gyp构建C ++插件,每次构建时都会收到以下警告:
warning C4996: 'v8::Object::Get': was declared deprecated
warning C4996: 'v8::Object::Get': was declared deprecated
与此代码有关,其中我从要解析的JSON中声明了 std :: string 变量:
void water(const FunctionCallbackInfo<Value> &args)
{
try{
namespace pt = boost::property_tree;
pt::ptree root;
pt::read_json("waterjson.json",root);
Local<Array> a = args[0].As<Array>();
Local<Array> b = args[1].As<Array>();
int total = 0;
for (std::size_t i = 0; i < a->Length(); i++)
{
v8::Isolate *isolate = args.GetIsolate();
v8::String::Utf8Value atr(isolate,a->Get(i));
std::string cppStr(*atr);
int c = root.get<int>(cppStr + ".content");
int s = root.get<int>(cppStr + ".serving");
int m = s / 100;
int amount = c * m;
v8::String::Utf8Value btr(isolate,b->Get(i));
std::string cppNum(*btr);
int num = stoi(cppNum);
total += (amount * num);
}
args.GetReturnValue().Set(total);
}
catch(int e)
{
args.GetReturnValue().Set(-e);
}
}
关于如何消除此错误的任何想法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。