Skip to content

Commit baef046

Browse files
addaleaxtargos
authored andcommitted
src: move Node-API version detection to where it is used
`src/js_native_api_types.h` and other files actually depend on the moved macros being evaluated, so before this change there was an implicit requirement that `src/js_native_api.h` would be included separately before any include of `src/js_native_api_types.h`, direct or transitive. PR-URL: #60512 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 92c484e commit baef046

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/js_native_api.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,6 @@
55
#include <stdbool.h> // NOLINT(modernize-deprecated-headers)
66
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
77

8-
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
9-
#define NAPI_VERSION_EXPERIMENTAL 2147483647
10-
#ifndef NAPI_VERSION
11-
#ifdef NAPI_EXPERIMENTAL
12-
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
13-
#else
14-
// The baseline version for N-API.
15-
// The NAPI_VERSION controls which version will be used by default when
16-
// compilling a native addon. If the addon developer specifically wants to use
17-
// functions available in a new version of N-API that is not yet ported in all
18-
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
19-
// depended on that version.
20-
#define NAPI_VERSION 8
21-
#endif
22-
#endif
23-
248
#include "js_native_api_types.h"
259

2610
// If you need __declspec(dllimport), either include <node_api.h> instead, or

src/js_native_api_types.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
#ifndef SRC_JS_NATIVE_API_TYPES_H_
22
#define SRC_JS_NATIVE_API_TYPES_H_
33

4+
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
5+
#define NAPI_VERSION_EXPERIMENTAL 2147483647
6+
#ifndef NAPI_VERSION
7+
#ifdef NAPI_EXPERIMENTAL
8+
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
9+
#else
10+
// The baseline version for N-API.
11+
// The NAPI_VERSION controls which version will be used by default when
12+
// compilling a native addon. If the addon developer specifically wants to use
13+
// functions available in a new version of N-API that is not yet ported in all
14+
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
15+
// depended on that version.
16+
#define NAPI_VERSION 8
17+
#endif
18+
#endif
19+
420
// This file needs to be compatible with C compilers.
521
// This is a public include file, and these includes have essentially
622
// became part of it's API.

0 commit comments

Comments
 (0)