John Smith John Smith - 1 year ago 78
C++ Question

Pass arguments to another function

Here I assign one Argument to the Handler:

const unsigned argc = 1;
v8::Local<v8::Value> argv[1] = { NanNew("hello world") };

NanMakeCallback(NanGetCurrentContext()->Global(), callHandle, argc, argv);

It works

But I want to assign two parameters! That is why I tried to do:

const unsigned argc = 2;
v8::Local<v8::Value> argv[1] = { NanNew("hello world") };
argv[2] = { NanNew("second argument") };

NanMakeCallback(NanGetCurrentContext()->Global(), callbackHandle, argc, argv);

But then I get this error: error: expected expression
argv[2] << { NanNew("second argument") };

What do I wrong? How can I assign two Arguments? Thanks

Answer Source

You seem to be creating an array of size 1:

v8::Local<v8::Value> argv[1] = { NanNew("hello world") };

Then trying to assign { NanNew("second argument") }; to its element with index 2. This won't work. Did you mean something like this:

v8::Local<v8::Value> argv[2] = { NanNew("hello world"), NanNew("second arg") };


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download