rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.23k stars 679 forks source link

Support for raw-dylib for Windows #2833

Open tbu- opened 1 month ago

tbu- commented 1 month ago

Currently, the following is generated:

extern "C" {
    #[doc = "[…]"]
    pub fn wmem_alloc(allocator: *mut wmem_allocator_t, size: usize)
        -> *mut ::std::os::raw::c_void;
}

I'd like to have an extra attribute there, for compilation to Windows:

#[cfg_attr(windows, link(name = "libwsutil.dll", kind = "raw-dylib"))]
extern "C" {
    #[doc = "[…]"]
    pub fn wmem_alloc(allocator: *mut wmem_allocator_t, size: usize)
        -> *mut ::std::os::raw::c_void;
}