-
Notifications
You must be signed in to change notification settings - Fork 79
Only enable C++20 when nodejs >= 23 #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the build configuration to conditionally enable C++20 only when Node.js is version 23 or higher, while using C++17 for lower versions.
- Introduces a new key to determine the major Node.js version.
- Applies conditional logic in the build flags for both Linux and Windows targets based on the Node.js version.
Comments suppressed due to low confidence (1)
binding.gyp:92
- Similarly, under the Windows section, 'cflags' is used for node_major_version >= 23 while 'cflags_cc' is used for node_major_version < 23. Using consistent keys could avoid unexpected behavior.
'cflags': [
binding.gyp
Outdated
| 'conditions': [ | ||
| [ | ||
| 'node_major_version >= 23', { | ||
| 'cflags': [ |
Copilot
AI
Mar 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of 'cflags' under the condition for node_major_version >= 23 is inconsistent with the use of 'cflags_cc' for node_major_version < 23. Consider standardizing the flag key (likely using 'cflags_cc') to prevent potential build issues.
| 'cflags': [ | |
| 'cflags_cc': [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables the use of C++20 only when Node.js version is 23 or above while falling back to C++17 otherwise, improving compatibility with older g++ versions.
- Introduces a new variable, node_major_version, extracted from Node.js version.
- Adds conditional blocks in both Linux and Windows targets to set the C++ standard appropriately.
Comments suppressed due to low confidence (1)
binding.gyp:15
- The node_major_version value is extracted as a string, which may cause unexpected behavior when used in numeric comparisons. Consider converting it to a number to ensure accurate condition evaluation.
'node_major_version': '<!(node -p "process.versions.node.split('.')[0]")',
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
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