Skip to content

Commit

Permalink
targets
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Feb 1, 2024
1 parent 095e648 commit 5a4a65d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
12 changes: 4 additions & 8 deletions crates/libs/targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
#[cfg(all(windows_raw_dylib, target_arch = "x86"))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern $abi {
$(#[$doc])?
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -22,10 +21,9 @@ macro_rules! link {
#[cfg(all(windows_raw_dylib, not(target_arch = "x86")))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern "C" {
$(#[$doc])?
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -36,10 +34,9 @@ macro_rules! link {
#[cfg(all(windows, not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
#[link(name = "windows.0.52.0")]
extern $abi {
$(#[$doc])?
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -50,9 +47,8 @@ macro_rules! link {
#[cfg(all(not(windows), not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
extern $abi {
$(#[$doc])?
pub fn $($function)*;
}
)
Expand Down
11 changes: 0 additions & 11 deletions crates/tests/targets/tests/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ fn link_name() {
}
}

#[test]
fn doc() {
windows_targets::link!("kernel32.dll" "system" "SetLastError" #[doc = "SetLastError"] fn SetLastError(code: u32) -> ());
windows_targets::link!("kernel32.dll" "system" #[doc = "GetLastError"] fn GetLastError() -> u32);

unsafe {
SetLastError(1234);
assert_eq!(GetLastError(), 1234);
}
}

#[test]
fn cdecl() {
windows_targets::link!("wldap32.dll" "cdecl" fn LdapMapErrorToWin32(code : i32) -> u32);
Expand Down

0 comments on commit 5a4a65d

Please sign in to comment.