node.jsc++17node-gypnode.js-addon

node-gyp ignores (c++17) cflag


I try to configure & build a node.js C++ addon with this binding.gyp file:

{ 
  "targets": [
    {
      "target_name": "addon",
      "sources": [ "addon.cpp" ],
      "cflags": [
        "-std=c++17"
      ]          
    }
  ]
}

But when I run node-gyp configure and node-gype rebuild I always get messages like

warning: ‘if constexpr’ only available with -std=c++17 or -std=gnu++17

The build also fails, because I really depend on these c++17 features. What am I doing wrong?


Solution

  • Using "cflags_cc" (instead of "cflags") works.

    This solved the problem.