Add cargo cfgs for opt in to newer standards
Currently unused, but will be needed when integrating std::optional or
std::string_view support.
[dependencies]
cxx = { version = "0.3", features = ["c++17"] }
diff --git a/Cargo.toml b/Cargo.toml
index 829eac3..db3b5e1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,11 @@
keywords = ["ffi"]
categories = ["development-tools::ffi", "api-bindings"]
+[features]
+default = [] # c++11
+"c++14" = []
+"c++17" = []
+
[dependencies]
cxxbridge-macro = { version = "=0.3.2", path = "macro" }
link-cplusplus = "1.0"
diff --git a/build.rs b/build.rs
index 9a071fe..a412dbd 100644
--- a/build.rs
+++ b/build.rs
@@ -3,7 +3,13 @@
.file("src/cxx.cc")
.cpp(true)
.cpp_link_stdlib(None) // linked via link-cplusplus crate
- .flag_if_supported("-std=c++11")
+ .flag_if_supported(if cfg!(feature = "c++17") {
+ "-std=c++17"
+ } else if cfg!(feature = "c++14") {
+ "-std=c++14"
+ } else {
+ "-std=c++11"
+ })
.compile("cxxbridge03");
println!("cargo:rerun-if-changed=src/cxx.cc");
println!("cargo:rerun-if-changed=include/cxx.h");