Skip to content
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

node-gyp ignores (c++17) cflag #1543

Closed
JlnWntr opened this issue Sep 14, 2018 · 4 comments
Closed

node-gyp ignores (c++17) cflag #1543

JlnWntr opened this issue Sep 14, 2018 · 4 comments

Comments

@JlnWntr
Copy link

JlnWntr commented Sep 14, 2018

  • Node Version: via package-manager
  • Platform: Ubuntu 16.04
  • Compiler: gcc-8
  • Module: my own

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?

@richardlau
Copy link
Member

Maybe try cflags_cc instead of cflags? It's what common.gypi uses: https://github.com/nodejs/node/blob/eaaee92d9b0be82d7f40b2abb67f30ce525d4bc4/common.gypi#L371

@JlnWntr
Copy link
Author

JlnWntr commented Sep 16, 2018

This works. Thanks.

@luizperes
Copy link

If you are on Mac, it is actually

...
"xcode_settings": {
  ...
  "OTHER_CFLAGS": [ "-std=c++17"],
},

It wouldn't work for me otherwise...

aosq pushed a commit to slackhq/tree-sitter-hack that referenced this issue Jul 30, 2020
@mceIdo
Copy link

mceIdo commented Jan 4, 2021

In case anyone reaches here and can't get windows builds to work - see #1662 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants