Skip to content

Commit 93f65c9

Browse files
committed
Bump C++ standard to C++20 for Node 24+
1 parent 38908df commit 93f65c9

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

utils/defaultCxxStandard.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
const targetSpecified = process.argv[2] !== 'none';
22

3-
let isNode18OrElectron20AndUp = false;
3+
let cxxStandard = '14';
44
if (targetSpecified) {
55
// Assume electron if target is specified.
66
// If building node 18 / 19 via target, will need to specify C++ standard manually
7-
const majorVersion = process.argv[2].split('.')[0];
8-
isNode18OrElectron20AndUp = majorVersion >= 20;
7+
const majorVersion = Number.parseInt(process.argv[2].split('.')[0]);
8+
if (majorVersion >= 20) {
9+
cxxStandard = '17';
10+
}
911
} else {
10-
// Node 18 === 108
11-
isNode18OrElectron20AndUp = Number.parseInt(process.versions.modules) >= 108;
12+
// Node 18 === 108, Node 24 === 137 (V8 headers require C++20)
13+
const moduleVersion = Number.parseInt(process.versions.modules);
14+
if (moduleVersion >= 137) {
15+
cxxStandard = '20';
16+
} else if (moduleVersion >= 108) {
17+
cxxStandard = '17';
18+
}
1219
}
1320

14-
const defaultCxxStandard = isNode18OrElectron20AndUp
15-
? '17'
16-
: '14';
17-
18-
process.stdout.write(defaultCxxStandard);
21+
process.stdout.write(cxxStandard);

0 commit comments

Comments
 (0)