Rollup merge of #87315 - ricobbe:raw-dylib-unstable-book, r=wesleywiser

Add docs for raw-dylib to unstable book
This commit is contained in:
Yuki Okushi 2021-07-28 18:28:13 +09:00 committed by GitHub
commit 911e22b57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,34 @@
# `raw_dylib`
The tracking issue for this feature is: [#58713]
[#58713]: https://github.com/rust-lang/rust/issues/58713
------------------------
The `raw_dylib` feature allows you to link against the implementations of functions in an `extern`
block without, on Windows, linking against an import library.
```rust,ignore (partial-example)
#![feature(raw_dylib)]
#[link(name="library", kind="raw-dylib")]
extern {
fn extern_function(x: i32);
}
fn main() {
unsafe {
extern_function(14);
}
}
```
## Limitations
Currently, this feature is only supported on `-windows-msvc` targets. Non-Windows platforms don't have import
libraries, and an incompatibility between LLVM and the BFD linker means that it is not currently supported on
`-windows-gnu` targets.
On the `i686-pc-windows-msvc` target, this feature supports only the `cdecl`, `stdcall`, `system`, and `fastcall`
calling conventions.