Status: New
Owner: ----

New issue 3668 by [email protected]: Get "error: type 'const Arguments' does not provide a subscript operator" when trying to call C++ function using JavaScript
https://code.google.com/p/v8/issues/detail?id=3668

I am trying to call C++ functions using V8 engine but failed.


Platform:
Mac OSX 10.9.2

v8:
Download from github.com/v8/v8.git
Should be the newest version
Able to build libv8.dylib into ./out/native
Able to build and run HelloWorld program from v8 official website using:
g++ -I./ ./samples/HelloWorld.cc – o ./samples/HelloWorld ./out/native/libv8.dylib

Problem:
Write three files sample_func.h sample_wrapper.h and sample_main.cc in ./samples/sample_function as the attachments show.
Try to build sample_main.cc using:
g++ -I./ -I./include -I./src ./samples/sample_function/sample_main.cc -l out/native/libv8.dylib
Error messages showed ups as below:

./samples/sample_function/sample_wrapper.h:13:15: error: type 'const Arguments' does not provide a subscript operator
  int x = args[0]->Uint32Value();
          ~~~~^~
./samples/sample_function/sample_wrapper.h:14:15: error: type 'const Arguments' does not provide a subscript operator
  int y = args[1]->Uint32Value();
          ~~~~^~
./samples/sample_function/sample_wrapper.h:15:38: error: too few arguments to function call, expected 2, have 1
  return Integer::New(sample_add(x,y));
         ~~~~~~~~~~~~                ^
./include/v8.h:2190:3: note: 'New' declared here
  static Local<Integer> New(Isolate* isolate, int32_t value);
  ^
./samples/sample_function/sample_main.cc:7:17: warning: using directive refers to implicitly-defined namespace 'std'
using namespace std;
                ^
./samples/sample_function/sample_main.cc:13:23: error: no member named 'New' in 'v8::String'
  global->Set(String::New("Add"), FunctionTemplate::New(Add));
              ~~~~~~~~^
1 warning and 4 errors generated.

Here class Arguments was declared in v8.h and I used the forward declaration in sample_wrapper.h. I have no idea why the compiler can’t find Argument definition. If adding #include “src/arguments.h” into sample_wrapper.h, the problem still exists.

Is it because of the include path problem?
I’ve already added ./include and ./src path to –I symbol so the compiler should be able to find all .h files inside these two folders.

Do you have any comments on it?
Or could you please help to build my code in your own machine and see the result?


Attachments:
        sample_code.7z  588 bytes

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to