Skip to main content

link

Macro link 

macro_rules! link {
    ($library:literal $abi:literal ordinal($ordinal:literal) fn $name:ident($($params:tt)*) $(-> $ret:ty)?) => { ... };
    ($library:literal $abi:literal $($link_name:literal)? fn $name:ident($($params:tt)*) $(-> $ret:ty)?) => { ... };
}
Expand description

Defines an external function to import.

Expands to an extern block declaring the function as well as a pub type alias matching the function’s signature. The type alias has the same name as the function, lives in the type namespace, and is useful for storing or passing around the function pointer (for example, after resolving the symbol at runtime via GetProcAddress).

An optional literal after the ABI selects a different export name. Use ordinal(N) in its place for an ordinal in 1..=65535. Use a documented stable ordinal or the target import library’s ordinal, not a number observed in one DLL build.