Skip to content

Commit 4e6f412

Browse files
authored
Only enable C++20 when nodejs >= 23 (#1092)
This patch implements to enable C++20 only when nodejs >= 23, which improve the compatibility with g++ lower versions, because C++20 only needed for nodejs >= 23. Fix: #1089
1 parent ff07c86 commit 4e6f412

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

binding.gyp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'runtime%': 'node',
1313
'ros_lib_dir': "<!(node -p \"require('./scripts/config.js').getROSLibPath()\")",
1414
'ros_include_root': "<!(node -p \"require('./scripts/config.js').getROSIncludeRootPath()\")",
15+
'node_major_version': '<!(node -p \"process.versions.node.split(\'.\')[0]\")',
1516
},
1617
'targets': [
1718
{
@@ -62,8 +63,21 @@
6263
'defines': [
6364
'OS_LINUX'
6465
],
65-
'cflags_cc': [
66-
'-std=c++20'
66+
'conditions': [
67+
[
68+
'node_major_version >= 23', {
69+
'cflags_cc': [
70+
'-std=c++20'
71+
]
72+
}
73+
],
74+
[
75+
'node_major_version < 23', {
76+
'cflags_cc': [
77+
'-std=c++17'
78+
]
79+
}
80+
]
6781
]
6882
}
6983
],
@@ -72,8 +86,21 @@
7286
'defines': [
7387
'OS_WINDOWS'
7488
],
75-
'cflags_cc': [
76-
'-std=c++20'
89+
'conditions': [
90+
[
91+
'node_major_version >= 23', {
92+
'cflags_cc': [
93+
'-std=c++20'
94+
]
95+
}
96+
],
97+
[
98+
'node_major_version < 23', {
99+
'cflags_cc': [
100+
'-std=c++17'
101+
]
102+
}
103+
]
77104
],
78105
'include_dirs': [
79106
'./src/third_party/dlfcn-win32/',

0 commit comments

Comments
 (0)