helgoboss / reaper-rs

Rust bindings for the REAPER C++ API
MIT License
82 stars 8 forks source link

Unable to compile example extension on Windows #80

Closed jamesWalker55 closed 3 months ago

jamesWalker55 commented 3 months ago

When I try to compile the example extension, I get this error:

error[E0599]: no method named `GetModuleFileName` found for reference `&'static Swell` in the current scope
   --> C:\Users\James\.cargo\git\checkouts\reaper-rs-d32fed07113e6874\8e06d9a\main\high\src\log_util.rs:145:22
    |
145 |         Swell::get().GetModuleFileName(hinstance.as_ptr(), buf, max_size as _)
    |                      ^^^^^^^^^^^^^^^^^ method not found in `&Swell`

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

It seems that function isn't available on Windows, it only compiles on unix:

    #[cfg(target_family = "unix")]
    #[doc = r" # Safety"]
    #[doc = r""]
    #[doc = r" REAPER can crash if you pass an invalid pointer."]
    pub unsafe fn GetModuleFileName(
        &self,
        hInst: root::HINSTANCE,
        fn_: *mut ::std::os::raw::c_char,
        nSize: root::DWORD,
    ) -> root::DWORD {
        match self.pointers.GetModuleFileName {
            None => panic!(
                "Attempt to use a function that has not been loaded: {}",
                stringify!(GetModuleFileName)
            ),
            Some(f) => f(hInst, fn_, nSize),
        }
    }
helgoboss commented 3 months ago

This is due to a change that I made yesterday and couldn't yet test on Windows. To be honest, I'm not taking much care to keep the master branch buildable because I'm not aware of anyone using reaper-rs except me. Do you actively use it?

jamesWalker55 commented 3 months ago

Ah no, I don't really use it actively. I was just exploring this project for the first time

For now I've just edited determine_module_path to return an empty string to get it to compile

helgoboss commented 3 months ago

If you revert the last commit, I think it should build on Windows.

helgoboss commented 3 months ago

Will fix this next week when I'm back at my Windows machine.