]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0455.md
Auto merge of #97057 - bjorn3:sync_cg_clif-2022-05-15, r=bjorn3
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0455.md
1 Some linking kinds are target-specific and not supported on all platforms.
2
3 Linking with `kind=framework` is only supported when targeting macOS,
4 as frameworks are specific to that operating system.
5
6 Similarly, `kind=raw-dylib` is only supported when targeting Windows-like
7 platforms.
8
9 Erroneous code example:
10
11 ```ignore (should-compile_fail-but-cannot-doctest-conditionally-without-macos)
12 #[link(name = "FooCoreServices", kind = "framework")] extern "C" {}
13 // OS used to compile is Linux for example
14 ```
15
16 To solve this error you can use conditional compilation:
17
18 ```
19 #[cfg_attr(target="macos", link(name = "FooCoreServices", kind = "framework"))]
20 extern "C" {}
21 ```
22
23 Learn more in the [Conditional Compilation][conditional-compilation] section
24 of the Reference.
25
26 [conditional-compilation]: https://doc.rust-lang.org/reference/attributes.html#conditional-compilation