use*_*417 5 node.js node-gyp c++17 node.js-addon
我尝试使用此\nbinding.gyp 文件配置并构建一个node.js C++ 插件:
\n\n{ \n "targets": [\n {\n "target_name": "addon",\n "sources": [ "addon.cpp" ],\n "cflags": [\n "-std=c++17"\n ] \n }\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但当我跑步node-gyp configure时node-gype rebuild n我总是收到类似的消息
\n\n\n警告:\xe2\x80\x98if constexpr\xe2\x80\x99 仅适用于 -std=c++17 或 -std=gnu++17
\n
构建也失败了,因为我真的依赖于这些 c++17 功能。我究竟做错了什么?
\ncflags cflags_cc 对我不起作用,但通过 VCCLCompilerTool 中的设置它可以工作(在 Windows 上):
{
'targets': [
{
'target_name': 'test-napi-native',
'sources': [ 'src/test_napi.cc' ],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'cflags': [ '-fno-exceptions' ],
'cflags_cc': [ '-fno-exceptions' ],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7'
},
'msvs_settings': {
'VCCLCompilerTool': { "ExceptionHandling": 1, 'AdditionalOptions': [ '-std:c++17' ] }
}
}
]
}
Run Code Online (Sandbox Code Playgroud)