From 4d856f6e91950fad32653d68efe7240848ae3446 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Mon, 1 Feb 2021 08:04:01 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node-addon-api/issues/888 PR-URL: https://github.com/nodejs/node-addon-api/pull/896 Reviewed-By: Nicola Del Gobbo --- napi-inl.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index ee1c37104..895e43768 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -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` with a custom Node.js // module name.