Skip to content

Commit 4ab952d

Browse files
authored
Merge pull request #202 from dtolnay/stdflag
Add cargo cfgs for opt in to newer standards
2 parents 14db1e2 + 9808ef1 commit 4ab952d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ exclude = ["/demo-cxx", "/gen", "/syntax", "/third-party"]
1313
keywords = ["ffi"]
1414
categories = ["development-tools::ffi", "api-bindings"]
1515

16+
[features]
17+
default = [] # c++11
18+
"c++14" = []
19+
"c++17" = []
20+
1621
[dependencies]
1722
cxxbridge-macro = { version = "=0.3.2", path = "macro" }
1823
link-cplusplus = "1.0"

build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ fn main() {
33
.file("src/cxx.cc")
44
.cpp(true)
55
.cpp_link_stdlib(None) // linked via link-cplusplus crate
6-
.flag_if_supported("-std=c++11")
6+
.flag_if_supported(if cfg!(feature = "c++17") {
7+
"-std=c++17"
8+
} else if cfg!(feature = "c++14") {
9+
"-std=c++14"
10+
} else {
11+
"-std=c++11"
12+
})
713
.compile("cxxbridge03");
814
println!("cargo:rerun-if-changed=src/cxx.cc");
915
println!("cargo:rerun-if-changed=include/cxx.h");

0 commit comments

Comments
 (0)