I'm trying to bind tbs.h
(TPM Based Services) via rust-bindgen.
I have the following header:
#ifndef TPM_WRAPPER_H
#define TPM_WRAPPER_H
#include <tbs.h>
#endif
The build.rs
file contains the path to the include directory of the Windows SDK:
use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rustc-link-lib=tbs");
println!("cargo:rerun-if-changed=include/tpm_wrapper.h");
let bindings = bindgen::Builder::default()
.header("include/tpm_wrapper.h")
.clang_arg("-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared")
.clang_arg("-v")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("tpm_bindings.rs"))
.expect("Couldn't write bindings!");
}
When I try to create the bindings via cargo build
and run the build script, I get the following errors:
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared\tbs.h:50:9: error: unknown type name 'UINT8'
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared\tbs.h:99:5: error: unknown type name '_In_'
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared\tbs.h:99:31: error: expected ')'
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared\tbs.h:98:20: note: to match this '('
Is there some clang configuration missing?