Files
vectorcraft/vendor/windows-link/src/lib.rs
T

58 lines
1.9 KiB
Rust

#![doc = include_str!("../readme.md")]
#![no_std]
/// Defines an external function to import.
#[cfg(all(windows, target_arch = "x86"))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
}
/// Defines an external function to import.
#[cfg(all(windows, not(target_arch = "x86"), not(target_vendor = "win7")))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
}
/// Defines an external function to import.
#[cfg(not(windows))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
extern $abi {
pub fn $($function)*;
}
)
}
// VectorCraft compatibility patch: windows-sys 0.61.2 binds CoTaskMemFree to
// combase.dll (Windows 8+). The same API is exported by ole32.dll on Windows 7.
// Redirect only this known API; leave every other binding unchanged.
#[cfg(all(windows, not(target_arch = "x86"), target_vendor = "win7"))]
#[macro_export]
macro_rules! link {
("combase.dll" $abi:literal fn CoTaskMemFree $($signature:tt)*) => (
$crate::link!("ole32.dll" $abi fn CoTaskMemFree $($signature)*);
);
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
}