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 <[email protected]>
  • Loading branch information
John French committed Feb 8, 2021
1 parent 41a1d56 commit c5e48e0
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 c5e48e0

Please sign in to comment.