rodrigocfd / winsafe

Windows API and GUI in safe, idiomatic Rust.
https://crates.io/crates/winsafe
MIT License
523 stars 30 forks source link

Build fails for the i686-pc-windows-(msvc/gnu) targets #98

Closed Refragg closed 1 year ago

Refragg commented 1 year ago

Hello, I've been trying to use this library's CommandLineToArgvW and it seems like it builds correctly on all 64 bits architectures but it fails to build on i686-pc-windows both MSVC and GNU. Here's what I'm getting when running cargo build --target i686-pc-windows-gnu:

error[E0599]: no method named `as_ptr` found for reference `&Self` in the current scope
   --> /home/refrag/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winsafe-0.0.17/src/user/handles/hwnd.rs:766:43
    |
766 |         unsafe { user::ffi::GetWindowLongW(self.as_ptr(), index.raw()) }
    |                                                 ^^^^^^ help: there is a method with a similar name: `ptr`

error[E0599]: no method named `as_ptr` found for reference `&Self` in the current scope
    --> /home/refrag/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winsafe-0.0.17/src/user/handles/hwnd.rs:1646:43
     |
1646 |         unsafe { user::ffi::SetWindowLongW(self.as_ptr(), index.raw(), new_long) }
     |                                                 ^^^^^^ help: there is a method with a similar name: `ptr`

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

Here's how it's imported in the project: winsafe = { version = "0.0.17", features = ["shell"], default-features = false }

I'm down to provide more details if needed, hope you have a nice day.

rodrigocfd commented 1 year ago

Hi,

Very strange error. Please try using the latest version, straight from the repo:

[dependencies]
winsafe = { git = "https://github.com/rodrigocfd/winsafe", features = [] }

And see if you have any success.

Refragg commented 1 year ago

Just tried it now, it is the exact same from the repository unfortunately.

rodrigocfd commented 1 year ago

Can you post the source code which is triggering this error, please?

Refragg commented 1 year ago

Sure, it is in this repo and more specifically here https://github.com/Refragg/obs-livesplit-one/blob/88dd5c751e93db9e506fb2bc7ca959835112d5d7/src/lib.rs#L739-L747

rodrigocfd commented 1 year ago

This is very odd. You're calling CommandLineToArgv, but the compilation error happens in GetWindowLong, which is completely unrelated.

Could you test the following simple program, and see what happens?

fn main() {
    match winsafe::CommandLineToArgv("a b c") {
        Ok(a) => println!("{:?}", a),
        Err(e) => println!("{:?}", e),
    }
}
Refragg commented 1 year ago

The same error appears at compile time with this simple example

rodrigocfd commented 1 year ago

In the end, it was just a minor syntax error: the handle method is called ptr(), not as_ptr().

Let me know if this works.

Refragg commented 1 year ago

Seems like it does fix it! Thank you for the quick fix!