我正在研究包含 C 和 C++ 源代码的 Node.js 本机模块。 node-gyp
用于构建模块。
因为我只希望在 C 代码中出现一个警告上升错误,所以我在 binding.gyp
中使用了以下几行:
"cflags!": [ "-Werror"],"cflags": [ "-Werror=implicit-function-declaration" ],
这在编译 C 代码时工作正常,但在每个 C++ 源文件上产生以下警告:
cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++
我找到了这个答案 - Apply C-specific gcc options to C/C++ mixed library - 它在使用“纯”CMake 时解决了同样的问题。不幸的是,我没有找到是否可能以及如何将此条件正确添加到 GYP 配置文件中 - 也许使用变量和条件?请让我知道它是否可以解决。谢谢。