Skip to content

Commit 4d856f6

Browse files
author
Gabriel Schulhof
committed
src: remove unnecessary symbol exposure
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: #888 PR-URL: #896 Reviewed-By: Nicola Del Gobbo <[email protected]>
1 parent f35bb7d commit 4d856f6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

napi-inl.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,11 @@ struct AccessorCallbackData {
344344
////////////////////////////////////////////////////////////////////////////////
345345

346346
// Register an add-on based on an initializer function.
347-
#define NODE_API_MODULE(modname, regfunc) \
348-
napi_value __napi_ ## regfunc(napi_env env, \
349-
napi_value exports) { \
350-
return Napi::RegisterModule(env, exports, regfunc); \
351-
} \
352-
NAPI_MODULE(modname, __napi_ ## regfunc)
347+
#define NODE_API_MODULE(modname, regfunc) \
348+
static napi_value __napi_##regfunc(napi_env env, napi_value exports) { \
349+
return Napi::RegisterModule(env, exports, regfunc); \
350+
} \
351+
NAPI_MODULE(modname, __napi_##regfunc)
353352

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

0 commit comments

Comments
 (0)