Skip to content

Commit 8ec5537

Browse files
authored
feat: bindgen fix and update (#38)
This PR does the following changes: - update of `bindgen` to `0.72` - addition of `opaque_type` in bindgen flags to work around alignment issues with virtual methods in MSFS SDK. This allows `cargo test` to run successfully. NOTE: with the update of bindgen from `0.69` to `0.72`, the size and alignment checks have been moved from unit tests to checks at compilation time. Without adding `opaque_type`, bindgen 0.69 fails tests, while bindgen 0.72 fails compilation. This change was tested with compilation of the a32nx and a380.
1 parent fbfeb55 commit 8ec5537

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

msfs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ futures = "0.3"
1212
libc = "0.2"
1313

1414
[build-dependencies]
15-
bindgen = "0.69"
15+
bindgen = "0.72"
1616
msfs_sdk = { path = "../msfs_sdk", version = "0.1.0" }
1717
cc = "1.0"

msfs/build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ fn main() {
3939
.blocklist_function("nvgStrokePaint")
4040
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
4141
.rustified_enum("SIMCONNECT_EXCEPTION")
42-
.impl_debug(false);
42+
.impl_debug(false)
43+
// `opaque_type` added to avoid alignment errors. These alignment errors are caused
44+
// because virtual methods are not well supported in rust-bindgen.
45+
.opaque_type("IGaugeCDrawableCreateParameters")
46+
.opaque_type("IGaugeCDrawableDrawParameters")
47+
.opaque_type("IGaugeCDrawable")
48+
.opaque_type("IGaugeCCallback")
49+
.opaque_type("ISerializableGaugeCCallback")
50+
.opaque_type("IAircraftCCallback")
51+
.opaque_type("IPanelCCallback")
52+
.opaque_type("IFSXPanelCCallback");
4353

4454
if wasm {
4555
bindings = bindings.clang_arg("-D_MSFS_WASM 1");

0 commit comments

Comments
 (0)