Closed
Description
Environment info
- Node.js version: v10.0.0
- node-addon-api version: 1.2.0
Steps to reproduce
Wrap functions from hello example to namespace:
diff --git a/1_hello_world/node-addon-api/hello.cc b/1_hello_world/node-addon-api/hello.cc
index 0957f53..f00bb77 100644
--- a/1_hello_world/node-addon-api/hello.cc
+++ b/1_hello_world/node-addon-api/hello.cc
@@ -1,5 +1,7 @@
#include <napi.h>
+namespace node_lib {
+
Napi::String Method(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
return Napi::String::New(env, "world");
@@ -11,4 +13,6 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
return exports;
}
-NODE_API_MODULE(hello, Init)
+}
+
+NODE_API_MODULE(hello, node_lib::Init)
Actual behavior
Compilation error
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/build'
CXX(target) Release/obj.target/hello/hello.o
In file included from /home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/node_modules/node-addon-api/napi.h:1487:0,
from ../hello.cc:1:
/home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/node_modules/node-addon-api/napi-inl.h:159:14: error: ‘__napi_node_lib’ has not been declared
napi_value __napi_ ## regfunc(napi_env env, \
^
../hello.cc:18:1: note: in expansion of macro ‘NODE_API_MODULE’
NODE_API_MODULE(hello, node_lib::Init)
^
In file included from /home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/node_modules/node-addon-api/napi.h:4:0,
from ../hello.cc:1:
/home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/node_modules/node-addon-api/napi-inl.h:163:24: error: ‘__napi_node_lib’ has not been declared
NAPI_MODULE(modname, __napi_ ## regfunc);
^
/home/kostya/.node-gyp/10.0.0/include/node/node_api.h:83:7: note: in definition of macro ‘NAPI_MODULE_X’
regfunc, \
^
/home/kostya/proj/abi-stable-node-addon-examples/1_hello_world/node-addon-api/node_modules/node-addon-api/napi-inl.h:163:3: note: in expansion of macro ‘NAPI_MODULE’
NAPI_MODULE(modname, __napi_ ## regfunc);
^
../hello.cc:18:1: note: in expansion of macro ‘NODE_API_MODULE’
NODE_API_MODULE(hello, node_lib::Init)
^
hello.target.mk:95: recipe for target 'Release/obj.target/hello/hello.o' failed
Expected behavior
No errors like with nan
version.
Metadata
Metadata
Assignees
Labels
No labels