Skip to content

Commit

Permalink
Merge pull request #111 from gyk/fix/windows-cpp
Browse files Browse the repository at this point in the history
Use C++ compiler on Windows if needed
  • Loading branch information
nlfiedler authored Nov 9, 2023
2 parents f020fd2 + 8edd324 commit 857085a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,17 @@ fn main() {
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
}

let bindings = builder.generate().unwrap();
let bindings = if cfg!(all(windows, target_pointer_width = "64")) {
match builder.clone().generate() {
Ok(bindings) => bindings,
Err(bindgen::BindgenError::ClangDiagnostic(err_msg)) if err_msg.contains("C++") => {
builder.clang_arg("-xc++").generate().unwrap()
}
Err(err) => panic!("{:?}", err),
}
} else {
builder.generate().unwrap()
};
let mut file = File::create(&bindings_path_str).expect("could not create bindings file");
// Work around the include! issue in rustc (as described in the
// rust-bindgen README file) by wrapping the generated code in a
Expand Down

0 comments on commit 857085a

Please sign in to comment.