Skip to content

library/windows_targets: Fix macro expansion error in 'link' macro #144417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions library/windows_targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ pub macro link_dylib {
}

#[cfg(feature = "windows_raw_dylib")]
pub macro link($($tt:tt)*) {
$crate::link_raw_dylib!($($tt)*)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message says the issue here is a missing semicolon so the fix is to simply append the semicolon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed that this would cause scoping issues. I followed the suggestion here: #144422

pub macro link{
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
#[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]
#[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]
unsafe extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
}

#[cfg(not(feature = "windows_raw_dylib"))]
Expand Down
Loading