Sequal32 / simconnect-rust

SimConnect bindings for rust.
MIT License
32 stars 13 forks source link

Can't build simconnect-rust #8

Closed MrMinimal closed 9 months ago

MrMinimal commented 9 months ago

Hi there,

first up: thank you for this project it has been a great pleasure working with it and I created a small project myself using simconnect (https://github.com/MrMinimal/better-radio-panel). For some bindgen related reason, I can't seem to get to compile simconnect though.

Using the instructions given in the README, using simconnect 0.1.3 as a dependency, I can't get it to work.

The error:

Tom@DESKTOP-7HHC8LQ MINGW64 ~/Dev/rust-test-simconnect/testing (master)
$ cargo build
   Compiling simconnect v0.1.4
error[E0793]: reference to packed field is unaligned
   --> C:\Users\Tom\Dev\rust-test-simconnect\testing\target\debug\build\simconnect-de6b5f38fdf1bde0\out/bindings.rs:628:522
    |
628 | ... ", " } else { "" } , v)) . collect :: < String > () , self . dwApplicationVersionMajor , self . dwApplicationVersionMinor , self . dwApplicati...
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
    = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
    = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)

Any clue on how to fix this?

MrMinimal commented 9 months ago

Using simconnect 0.2.0 fixes these issues completely

Sequal32 commented 9 months ago

Thanks for the report, and I've updated the README to reflect the solution.