Skip to content

Commit

Permalink
src: remove unnecessary symbol exposure
Browse files Browse the repository at this point in the history
The symbol generated by `NODE_API_MODULE()` is exposed unnecessarily.
It is sufficient for it to be a local symbol because it is passed
around as a function pointer. Furthermore, making it `static` fixes a
warning.

Fixes: nodejs/node-addon-api#888
PR-URL: nodejs/node-addon-api#896
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@gmail.com>
  • Loading branch information
kevindavies8 committed Feb 8, 2021
1 parent 48e4327 commit 5a890e6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,11 @@ struct AccessorCallbackData {
////////////////////////////////////////////////////////////////////////////////

// Register an add-on based on an initializer function.
#define NODE_API_MODULE(modname, regfunc) \
napi_value __napi_ ## regfunc(napi_env env, \
napi_value exports) { \
return Napi::RegisterModule(env, exports, regfunc); \
} \
NAPI_MODULE(modname, __napi_ ## regfunc)
#define NODE_API_MODULE(modname, regfunc) \
static napi_value __napi_##regfunc(napi_env env, napi_value exports) { \
return Napi::RegisterModule(env, exports, regfunc); \
} \
NAPI_MODULE(modname, __napi_##regfunc)

// Register an add-on based on a subclass of `Addon<T>` with a custom Node.js
// module name.
Expand Down

0 comments on commit 5a890e6

Please sign in to comment.