Naios / powersaver

Manages Windows Power Plans automatically based on running process names
GNU General Public License v3.0
13 stars 1 forks source link

Unable to compile #2

Closed LeoKesler closed 1 year ago

LeoKesler commented 1 year ago

Hi. I am new to Rust. I am trying to compile but I am getting these errors, with the original source code, without any changes.


error[E0793]: reference to packed field is unaligned
    --> C:\Users\Leonardo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52
     |
2783 |         *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = 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)

error[E0793]: reference to packed field is unaligned
    --> C:\Users\Leonardo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2807:25
     |
2807 |         ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = 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)

For more information about this error, try `rustc --explain E0793`.
error: could not compile `ntapi` (lib) due to 2 previous errors ```

Can you check the source code  ?

My objective is to change the program to use the Power save plan for default and High Performance to selected apps. 
Thanks.
Naios commented 1 year ago

@LeoKesler I have fixed it, was caused by a dependency updated in a non-semver compatible way. It should work on the updated version of powersaver and the latest rust release.