nodejs / nan

Native Abstractions for Node.js
MIT License
3.27k stars 501 forks source link

error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv' #923

Closed matteodisabatino closed 2 years ago

matteodisabatino commented 2 years ago

Got this error while compiling using prebuild. Here all the stack:

In file included from ../src/gc_info.cc:5:
In file included from ../node_modules/nan/nan.h:58:
In file included from /var/folders/b1/nkhppp291574ww7ftwplz6t80000gn/T/prebuild/node/16.13.0/include/node/node.h:63:
In file included from /var/folders/b1/nkhppp291574ww7ftwplz6t80000gn/T/prebuild/node/16.13.0/include/node/v8.h:30:
/var/folders/b1/nkhppp291574ww7ftwplz6t80000gn/T/prebuild/node/16.13.0/include/node/v8-internal.h:492:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
            !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:710:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
1 error generated.
make: *** [Release/obj.target/gc_info/src/gc_info.o] Error 1
addaleax commented 2 years ago

It means that your compiler is outdated (or, rather, the C++ standard library headers are, but usually their versions are tied to compiler versions).

matteodisabatino commented 2 years ago

Hi, thanks for your answer. I updated to macOS Monterey few days ago and I installed the latest Xcode Command Line Tools, so I don't know how it could be possibile.

Here my clang version:

Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
fivdi commented 2 years ago

Maybe the option -std=c++14 needs to be passed to clang? See https://github.com/nodejs/node/issues/38367

matteodisabatino commented 2 years ago

You gotta reason: with flag -std=c++14 my problem has been solved. Thanks you so much.

matteodisabatino commented 2 years ago

@fivdi I've made some tests and I've seen that with these simple settings:

"conditions": [
    ["OS=='mac'", {
        "xcode_settings": {
            "MACOSX_DEPLOYMENT_TARGET": "10.9"
        }
    }]
]

Compilation works fine and there is no need to specify this:

"conditions": [
    ["OS=='mac'", {
        "xcode_settings": {
            "OTHER_CFLAGS": [
              "-std=c++14"
            ]
        }
    }]
]

I don't know if it could be useful.

fivdi commented 2 years ago

I think I'd prefer "MACOSX_DEPLOYMENT_TARGET": "10.9" over "OTHER_CFLAGS": ["-std=c++14"]. serialport also does it that way, see here.

matteodisabatino commented 2 years ago

Happy to hear. I agree.