Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent compilation error on Node 12 (ref #1742) #1843

Merged
merged 1 commit into from Apr 25, 2019

Conversation

jacobq
Copy link
Contributor

@jacobq jacobq commented Apr 23, 2019

I think this fixes a slight oversight that prevents it from building against node v12.x but would appreciate review from someone more familiar with nan, v8, etc.


Without this, attempting to build against Node v12.0.0 on Linux leads to the below error:

../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:41:75: error: no matching function for call to ‘v8::String::Utf8Value::Utf8Value(v8::Local<v8::String>)’
   v8::String::Utf8Value path(Nan::To<v8::String>(info[0]).ToLocalChecked());
                                                                           ^
In file included from /home/user/.node-gyp/12.0.0/include/node/node.h:63:0,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/user/.node-gyp/12.0.0/include/node/v8.h:2995:5: note: candidate: v8::String::Utf8Value::Utf8Value(v8::Isolate*, v8::Local<v8::Value>)
     Utf8Value(Isolate* isolate, Local<v8::Value> obj);
     ^~~~~~~~~
/home/user/.node-gyp/12.0.0/include/node/v8.h:2995:5: note:   candidate expects 2 arguments, 1 provided

And attempting to build again Node v10.15.3 on Linux leads to the below warning:

../src/serialport.cpp:41:75: warning: ‘v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)’ is deprecated: Use Isolate version [-Wdeprecated-declarations]
@serialport/bindings:    v8::String::Utf8Value path(Nan::To<v8::String>(info[0]).ToLocalChecked());
@serialport/bindings:                                                                            ^
@serialport/bindings: In file included from /home/user/.node-gyp/10.15.3/include/node/v8.h:26:0,
@serialport/bindings:                  from /home/user/.node-gyp/10.15.3/include/node/node.h:63,
@serialport/bindings:                  from ../node_modules/nan/nan.h:53,
@serialport/bindings:                  from ../src/./serialport.h:6,
@serialport/bindings:                  from ../src/serialport.cpp:1:
@serialport/bindings: /home/user/.node-gyp/10.15.3/include/node/v8.h:2892:28: note: declared here
@serialport/bindings:                    explicit Utf8Value(Local<v8::Value> obj));

@jacobq
Copy link
Contributor Author

jacobq commented Apr 23, 2019

I think this fixes #1742 though it evidently breaks in Node v6.x

@reconbot
Copy link
Member

Cc @indutny

Without this, attempting to build against Node v12.0.0 on Linux leads to the below error:
```
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:41:75: error: no matching function for call to ‘v8::String::Utf8Value::Utf8Value(v8::Local<v8::String>)’
   v8::String::Utf8Value path(Nan::To<v8::String>(info[0]).ToLocalChecked());
                                                                           ^
In file included from /home/user/.node-gyp/12.0.0/include/node/node.h:63:0,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/user/.node-gyp/12.0.0/include/node/v8.h:2995:5: note: candidate: v8::String::Utf8Value::Utf8Value(v8::Isolate*, v8::Local<v8::Value>)
     Utf8Value(Isolate* isolate, Local<v8::Value> obj);
     ^~~~~~~~~
/home/user/.node-gyp/12.0.0/include/node/v8.h:2995:5: note:   candidate expects 2 arguments, 1 provided
```

And attempting to build again Node v10.15.3 on Linux leads to the below warning:
```
../src/serialport.cpp:41:75: warning: ‘v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)’ is deprecated: Use Isolate version [-Wdeprecated-declarations]
@serialport/bindings:    v8::String::Utf8Value path(Nan::To<v8::String>(info[0]).ToLocalChecked());
@serialport/bindings:                                                                            ^
@serialport/bindings: In file included from /home/user/.node-gyp/10.15.3/include/node/v8.h:26:0,
@serialport/bindings:                  from /home/user/.node-gyp/10.15.3/include/node/node.h:63,
@serialport/bindings:                  from ../node_modules/nan/nan.h:53,
@serialport/bindings:                  from ../src/./serialport.h:6,
@serialport/bindings:                  from ../src/serialport.cpp:1:
@serialport/bindings: /home/user/.node-gyp/10.15.3/include/node/v8.h:2892:28: note: declared here
@serialport/bindings:                    explicit Utf8Value(Local<v8::Value> obj));
```
@jacobq jacobq force-pushed the fix-path-conversion-for-node12 branch from eea40fd to 79a8dfb Compare April 24, 2019 22:34
@jacobq jacobq changed the title fix: use isolate version of v8::String::Utf8Value (ref #1742) fix: prevent compilation error on Node 12 (ref #1742) Apr 24, 2019
@jacobq
Copy link
Contributor Author

jacobq commented Apr 24, 2019

Note: Revised per @fivdi's suggestion. 🙏 This should circumvent the problem on node v6. 🤞

@reconbot
Copy link
Member

cool, Lets do it!

@reconbot reconbot merged commit 00dc272 into serialport:master Apr 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants