0

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

両方で同じエラーが発生します。

4

2 に答える 2

1

エラーメッセージに基づいて、次のことを試してください。

Local<String> source = String::New("Hi");
于 2012-07-02T04:05:41.450 に答える
0

このコードを試してください:

HandleScope handle_scope;
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Handle<String> source = String::New("'Hello' + ', World!'");
Handle<Script> script = Script::Compile(source);
TryCatch trycatch;
Handle<Value> result = script->Run();   
if ( result.IsEmpty() ) {
    Handle<Value> excep = trycatch.Exception();
    String::AsciiValue excep_str(excep);
    printf("%s\n",*excep);
}  else {
    String::AsciiValue ascii(result);
    printf("%s\n", *ascii);
}
context.Dispose();
return 0;
于 2012-07-04T08:54:21.823 に答える