我正在尝试tbs.h
通过 rust-bindgen 绑定(基于 TPM 的服务)。
我有以下标题:
#ifndef TPM_WRAPPER_H
#define TPM_WRAPPER_H
#include <tbs.h>
#endif
该build.rs
文件包含 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!");
}
当我尝试通过创建绑定cargo build
并运行构建脚本时,出现以下错误:
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 '('
是否缺少一些clang配置?