Skip to content

Commit a890576

Browse files
authored
Fix build errors and warnings on Mac (#46)
1 parent e4f6030 commit a890576

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ To use N-API in a native module:
3232
```gyp
3333
'cflags!': [ '-fno-exceptions' ],
3434
'cflags_cc!': [ '-fno-exceptions' ],
35-
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' },
35+
'xcode_settings': {
36+
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
37+
'CLANG_CXX_LIBRARY': 'libc++',
38+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
39+
},
3640
'msvs_settings': {
3741
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
3842
},

napi-inl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ PropertyDescriptor::Accessor(const char* utf8name,
19431943
void* data) {
19441944
typedef details::CallbackData<Getter, Napi::Value> CbData;
19451945
// TODO: Delete when the function is destroyed
1946-
auto callbackData = new CbData({ getter });
1946+
auto callbackData = new CbData({ getter, nullptr });
19471947

19481948
return PropertyDescriptor({
19491949
utf8name,
@@ -1972,7 +1972,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
19721972
void* data) {
19731973
typedef details::CallbackData<Getter, Napi::Value> CbData;
19741974
// TODO: Delete when the function is destroyed
1975-
auto callbackData = new CbData({ getter });
1975+
auto callbackData = new CbData({ getter, nullptr });
19761976

19771977
return PropertyDescriptor({
19781978
nullptr,
@@ -2066,7 +2066,7 @@ inline PropertyDescriptor PropertyDescriptor::Function(const char* utf8name,
20662066
typedef decltype(cb(CallbackInfo(nullptr, nullptr))) ReturnType;
20672067
typedef details::CallbackData<Callable, ReturnType> CbData;
20682068
// TODO: Delete when the function is destroyed
2069-
auto callbackData = new CbData({ cb });
2069+
auto callbackData = new CbData({ cb, nullptr });
20702070

20712071
return PropertyDescriptor({
20722072
utf8name,
@@ -2096,7 +2096,7 @@ inline PropertyDescriptor PropertyDescriptor::Function(napi_value name,
20962096
typedef decltype(cb(CallbackInfo(nullptr, nullptr))) ReturnType;
20972097
typedef details::CallbackData<Callable, ReturnType> CbData;
20982098
// TODO: Delete when the function is destroyed
2099-
auto callbackData = new CbData({ cb });
2099+
auto callbackData = new CbData({ cb, nullptr });
21002100

21012101
return PropertyDescriptor({
21022102
nullptr,

test/arraybuffer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Value CreateExternalBufferWithFinalize(const CallbackInfo& info) {
6161
data,
6262
testLength,
6363
[](Env env, void* finalizeData) {
64-
delete[] finalizeData;
64+
delete[] static_cast<uint8_t*>(finalizeData);
6565
finalizeCount++;
6666
});
6767

@@ -88,7 +88,7 @@ Value CreateExternalBufferWithFinalizeHint(const CallbackInfo& info) {
8888
data,
8989
testLength,
9090
[](Env env, void* finalizeData, char* finalizeHint) {
91-
delete[] finalizeData;
91+
delete[] static_cast<uint8_t*>(finalizeData);
9292
finalizeCount++;
9393
},
9494
hint);

test/binding.gyp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
'dependencies': ["<!(node -p \"require('../').gyp\")"],
1919
'cflags!': [ '-fno-exceptions' ],
2020
'cflags_cc!': [ '-fno-exceptions' ],
21-
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' },
21+
'xcode_settings': {
22+
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
23+
'CLANG_CXX_LIBRARY': 'libc++',
24+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
25+
},
2226
'msvs_settings': {
2327
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
2428
},

0 commit comments

Comments
 (0)