【发布时间】:2012-07-02 03:44:51
【问题描述】:
我正在尝试为 V8 编译 hello world 示例,但一直遇到编译时错误。代码如下:
#include <v8/src/v8.h>
using namespace v8;
int main(int argc, char* argv[]) {
// Create a string holding the JavaScript source code.
String source = String::New("Hi");
// Compile it.
Script script = Script::Compile(source) ;
// Run it.
Value result = script->Run();
// Convert the result to an ASCII string and display it.
String::AsciiValue ascii(result) ;
printf("%s\n", *ascii) ;
return 0;
}
这是编译错误:
error: conversion from ‘v8::Local<v8::String>’ to non-scalar type ‘v8::String’ requested
第 8 行的错误是:String source = String::New("Hi");
我已经尝试用谷歌搜索这个错误,但似乎找不到有意义的修复方法。有什么想法吗?
我都试过了:
svn 结帐http://v8.googlecode.com/svn/trunk/v8
和
svn 结帐http://v8.googlecode.com/svn/branches/bleeding_edge/v8
两者都得到相同的错误。
【问题讨论】:
-
哪一行给出了错误?
-
第 8 行出现错误。我更新了帖子以反映这一点。
-
您尝试的代码大致解释了发生了什么。您应该使用的真实代码位于本文后面。