I've took a simple piece of code from the NodeJS core (crypto) :
ASSERT_IS_BUFFER(args[0]);
ssize_t klen = Buffer::Length(args[0]);
However when compiling this with node-gyp
in my own native extension, I get the following error :
../deps/v8/include/v8.h:202:5: error: assigning to 'v8::Object *volatile' from incompatible type
'v8::Value *'
TYPE_CHECK(T, S);
^
../deps/v8/include/v8.h:145:37: note: expanded from macro 'TYPE_CHECK'
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
^
../src/openssljs.cc:300:33: note: in instantiation of function template specialization 'v8::Handle<v8::Object>::Handle<v8::Value>'
requested here
ssize_t klen = Buffer::Length(args[0]);
^
Any idea what could be causing this?
You took those lines from one version of node (e.g. from HEAD) but header files in your system belong to other version of node.
In the old version Buffer::Length
was accepting v8::Handle<v8::Object>
while in newer it accepts v8::Handle<v8::Value>
which matches the type of args[0]
.
Commit that changed the signature: https://github.com/joyent/node/commit/c8c638a84195e5571f4ece881375909e1f4b82a8
You can either update node.js installed in your system or use an explicit cast: args[0].As<Object>()