Fix for `windows-targets::link` doc compatibility (#2868)
This commit is contained in:
Родитель
0494b0245e
Коммит
428a7ca2e6
|
@ -1,7 +1,7 @@
|
|||
|
||||
[package]
|
||||
name = "windows-targets"
|
||||
version = "0.52.1"
|
||||
version = "0.52.2"
|
||||
authors = ["Microsoft"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
|
|
|
@ -8,7 +8,7 @@ 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)? fn $($function:tt)*) => (
|
||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
||||
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
|
||||
extern $abi {
|
||||
$(#[link_name=$link_name])?
|
||||
|
@ -21,7 +21,7 @@ macro_rules! link {
|
|||
#[cfg(all(windows_raw_dylib, not(target_arch = "x86")))]
|
||||
#[macro_export]
|
||||
macro_rules! link {
|
||||
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
|
||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
||||
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
|
||||
extern "C" {
|
||||
$(#[link_name=$link_name])?
|
||||
|
@ -34,7 +34,7 @@ macro_rules! link {
|
|||
#[cfg(all(windows, not(windows_raw_dylib)))]
|
||||
#[macro_export]
|
||||
macro_rules! link {
|
||||
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
|
||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
||||
#[link(name = "windows.0.52.1")]
|
||||
extern $abi {
|
||||
$(#[link_name=$link_name])?
|
||||
|
@ -47,7 +47,7 @@ macro_rules! link {
|
|||
#[cfg(all(not(windows), not(windows_raw_dylib)))]
|
||||
#[macro_export]
|
||||
macro_rules! link {
|
||||
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
|
||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
||||
extern $abi {
|
||||
pub fn $($function)*;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,17 @@ 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче