nodejs/nan

error: assigning to 'v8::Object *volatile' from incompatible type 'v8::Primitive *'

Closed this issue · 1 comments

Disclaimer: I'm new to C++ addons. I'm converting an existing one to include NAN.

I get this error about Uncompilable<Object>();. Would this error come from NAN or from Node it self?

This is the compilation error I get

/Users/ericyen/.node-gyp/0.11.14/deps/v8/include/v8.h:596:5: error: assigning to 'v8::Object *volatile' from incompatible type 'v8::Primitive *'
    TYPE_CHECK(O, Primitive);
    ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/ericyen/.node-gyp/0.11.14/deps/v8/include/v8.h:167:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
/Users/ericyen/.node-gyp/0.11.14/deps/v8/include/v8.h:592:5: note: in instantiation of function template specialization 'v8::NonCopyablePersistentTraits<v8::Function>::Uncompilable<v8::Object>'
      requested here
    Uncompilable<Object>();
    ^
/Users/ericyen/.node-gyp/0.11.14/deps/v8/include/v8.h:5741:6: note: in instantiation of function template specialization 'v8::NonCopyablePersistentTraits<v8::Function>::Copy<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >' requested here
  M::Copy(that, this);
     ^
/Users/ericyen/.node-gyp/0.11.14/deps/v8/include/v8.h:657:5: note: in instantiation of function template specialization 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function>
      >::Copy<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >' requested here
    Copy(that);
    ^
../fuse4js.cc:683:30: note: in instantiation of member function 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >::Persistent' requested here
  Persistent<Function> tpl = f4js.GenericFunc; // default
                             ^

f4js.GenericFunc is a Persistent function. It is declared at the start of the file, and it is assigned like this NanAssignPersistent(f4js.GenericFunc, NanNew<FunctionTemplate>(GenericCompletion)->GetFunction());

Any suggestions would be really helpful.
Thanks

You cannot directly assign Persistents. They are intentionally unassignable. You can declare an uninitialized Persistent and use NanAssignPersistent to initialize it.