完美

[学习|工作|博客|交流平台|完美起航]
 问题描述
时间:[ 2017-05-17 16:10:53 ]作者:[ zyw327 ]

使用node开发c/c++插件,报如下错误,求指教!

make: Entering directory `/data/node/project/cpp/build'
  CXX(target) Release/obj.target/addon/hello.o
../hello.cc: In function ‘void Prime::Prime(const v8::FunctionCallbackInfo<v8::Value>&)’:
../hello.cc:51:18: error: invalid conversion from ‘void*’ to ‘int*’ [-fpermissive]
    all = malloc(1);
                  ^
../hello.cc:59:12: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
  result[1] = all;
            ^
../hello.cc:60:16: error: conflicting declaration ‘v8::Local<v8::Number> result’
  Local<Number> result = Number::New(isolate, result);
                ^
../hello.cc:23:6: error: ‘result’ has a previous declaration as ‘int result [2]’
  int result[2];
      ^
../hello.cc:60:52: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, int [2])’
  Local<Number> result = Number::New(isolate, result);
                                                    ^
../hello.cc:60:52: note: candidate is:
In file included from /root/.node-gyp/7.7.4/include/node/node.h:42:0,
                 from ../hello.cc:1:
/root/.node-gyp/7.7.4/include/node/v8.h:2757:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
   static Local<Number> New(Isolate* isolate, double value);
                        ^
/root/.node-gyp/7.7.4/include/node/v8.h:2757:24: note:   no known conversion for argument 2 from ‘int [2]’ to ‘double’
../hello.cc:39:9: warning: unused variable ‘value’ [-Wunused-variable]
  double value = args[0]->NumberValue() + args[1]->NumberValue();
         ^
In file included from /root/.node-gyp/7.7.4/include/node/node.h:42:0,
                 from ../hello.cc:1:
/root/.node-gyp/7.7.4/include/node/v8.h: In instantiation of ‘void v8::ReturnValue<T>::Set(S*) [with S = int; T = v8::Value]’:
../hello.cc:61:34:   required from here
/root/.node-gyp/7.7.4/include/node/v8.h:191:37: error: cannot convert ‘v8::Primitive*’ to ‘int** volatile’ in assignment
     *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                     ^
/root/.node-gyp/7.7.4/include/node/v8.h:8695:3: note: in expansion of macro ‘TYPE_CHECK’
   TYPE_CHECK(S*, Primitive);
   ^
make: *** [Release/obj.target/addon/hello.o] Error 1
make: Leaving directory `/data/node/project/cpp/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/node/lib/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.10.0-327.el7.x86_64
gyp ERR! command "/usr/local/node/bin/node" "/usr/bin/node-gyp" "build"
gyp ERR! cwd /data/node/project/cpp
gyp ERR! node -v v7.7.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok


 相关评论