| 1 | //! Provides the `link!` macro used by the generated windows bindings. |
| 2 | //! |
| 3 | //! This is a simple wrapper around an `extern` block with a `#[link]` attribute. |
| 4 | //! It's very roughly equivalent to the windows-targets crate. |
| 5 | |
| 6 | macro_rules! link_macro { |
| 7 | ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => ( |
| 8 | // Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't |
| 9 | // have in this repo. So instead we always link kernel32.lib and add the rest of the import |
| 10 | // libraries below by using an empty extern block. This works because extern blocks are not |
| 11 | // connected to the library given in the #[link] attribute. |
| 12 | #[link(name = "kernel32")] |
| 13 | extern $abi { |
| 14 | $(#[link_name=$link_name])? |
| 15 | pub fn $($function)*; |
| 16 | } |
| 17 | ) |
| 18 | } |
| 19 | pub(crate) use link_macro as link; |