Skip to content

Commit 037ff3d

Browse files
vmorozBethGriggs
authored andcommitted
node-api: explicitly set __cdecl for API functions
PR-URL: #42780 Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent c535db1 commit 037ff3d

6 files changed

+973
-908
lines changed

src/js_native_api.h

+367-363
Large diffs are not rendered by default.

src/js_native_api_types.h

+13-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
typedef uint16_t char16_t;
1212
#endif
1313

14+
#ifndef NAPI_CDECL
15+
#ifdef _WIN32
16+
#define NAPI_CDECL __cdecl
17+
#else
18+
#define NAPI_CDECL
19+
#endif
20+
#endif
21+
1422
// JSVM API types are all opaque pointers for ABI stability
1523
// typedef undefined structs instead of void* for compile time type safety
1624
typedef struct napi_env__* napi_env;
@@ -100,10 +108,11 @@ typedef enum {
100108
// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
101109
// added value(s).
102110

103-
typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info);
104-
typedef void (*napi_finalize)(napi_env env,
105-
void* finalize_data,
106-
void* finalize_hint);
111+
typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
112+
napi_callback_info info);
113+
typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
114+
void* finalize_data,
115+
void* finalize_hint);
107116

108117
typedef struct {
109118
// One of utf8name or name should be NULL.

0 commit comments

Comments
 (0)