dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 320 forks source link

c++20 flags not being passed to msvc? #1312

Closed Keshi closed 4 months ago

Keshi commented 4 months ago

It appears that c++20 flags are not being passed to msvc when the c++20 feature is enabled

demo.cc:

#include <compare>
void check() {
    auto res = 1 <=> 2;
}

cargo.toml:

[package]
name = "rustlib"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "rustlib"
crate-type = ["staticlib"]
[dependencies]
cxx = {version  = "1.0.115", features = ["c++20"]}
[build-dependencies]
cxx-build = "1.0.115"
cargo build
running: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "D:\\...\\target\\debug\\build\\rustlib-0398cc2d1afc7067\\out\\cxxbridge\\include" "-I" "D:\\...\\target\\debug\\build\\rustlib-0398cc2d1afc7067\\out\\cxxbridge\\crate" "-W4" "-FoD:\\...\\target\\debug\\build\\rustlib-0398cc2d1afc7067\\out\\src/demo.o" "-c" "src/demo.cc"
  demo.cc
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\compare(12): warning STL4038: The contents of <compare> are available only with C++20 or later.
  src/demo.cc(3): error C2059: syntax error: '>'
  exit code: 2
Keshi commented 4 months ago

Actually, this looks like it may be more of a cc issue.