Skip to content

Commit

Permalink
Add no_exceptions feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiltd committed Apr 22, 2024
1 parent d5dd976 commit 4fcf972
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ default = ["std", "cxxbridge-flags/default"] # c++11
"c++14" = ["cxxbridge-flags/c++14"]
"c++17" = ["cxxbridge-flags/c++17"]
"c++20" = ["cxxbridge-flags/c++20"]
"no_exceptions" = ["cxxbridge-flags/no_exceptions"]
alloc = []
std = ["alloc"]

Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fn main() {
.cpp(true)
.cpp_link_stdlib(None) // linked via link-cplusplus crate
.std(cxxbridge_flags::STD)
.define(cxxbridge_flags::EXCEPTIONS, None)
.warnings_into_errors(cfg!(deny_warnings))
.compile("cxxbridge1");

Expand Down
1 change: 1 addition & 0 deletions flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ default = [] # c++11
"c++14" = []
"c++17" = []
"c++20" = []
"no_exceptions" = []

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
11 changes: 10 additions & 1 deletion flags/src/impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[allow(unused_assignments, unused_mut, unused_variables)]
#![allow(unused_assignments, unused_mut, unused_variables)]
pub const STD: &str = {
let mut flag = "c++11";

Expand All @@ -13,3 +13,12 @@ pub const STD: &str = {

flag
};

pub const EXCEPTIONS: &str = {
let mut flag = "RUST_CXX_ALLOW_EXCEPTIONS";

#[cfg(feature = "no_exceptions")]
(flag = "RUST_CXX_NO_EXCEPTIONS");

flag
};

0 comments on commit 4fcf972

Please sign in to comment.