diff --git a/packages/emnapi/include/js_native_api.h b/packages/emnapi/include/js_native_api.h index d665052b..70d7de3a 100644 --- a/packages/emnapi/include/js_native_api.h +++ b/packages/emnapi/include/js_native_api.h @@ -21,6 +21,12 @@ #endif #endif +#ifndef EMNAPI_UNMODIFIED_UPSTREAM +#if !defined(NAPI_EXTERN) && defined(__EMSCRIPTEN__) +#define NAPI_EXTERN __attribute__((__import_module__("env"))) +#endif +#endif + #include "js_native_api_types.h" // If you need __declspec(dllimport), either include instead, or diff --git a/packages/emnapi/include/node_api.h b/packages/emnapi/include/node_api.h index 49a23aed..a12ad129 100644 --- a/packages/emnapi/include/node_api.h +++ b/packages/emnapi/include/node_api.h @@ -1,6 +1,16 @@ #ifndef SRC_NODE_API_H_ #define SRC_NODE_API_H_ +#ifndef EMNAPI_UNMODIFIED_UPSTREAM +#ifndef BUILDING_NODE_EXTENSION +#define BUILDING_NODE_EXTENSION +#endif + +#if !defined(NAPI_EXTERN) && defined(__EMSCRIPTEN__) +#define NAPI_EXTERN __attribute__((__import_module__("env"))) +#endif +#endif + #if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN) #ifdef _WIN32 // Building native addon against node