]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_error_codes/src/error_codes/E0791.md
New upstream version 1.67.1+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0791.md
CommitLineData
487cf647
FG
1Static variables with the `#[linkage]` attribute within external blocks
2must have one of the following types, which are equivalent to a nullable
3pointer in C:
4
5* `*mut T` or `*const T`, where `T` may be any type.
6
7* An enumerator type with no `#[repr]` attribute and with two variants, where
8 one of the variants has no fields, and the other has a single field of one of
9 the following non-nullable types:
10 * Reference type
11 * Function pointer type
12
13 The variants can appear in either order.
14
15For example, the following declaration is invalid:
16
17```compile_fail,E0791
18#![feature(linkage)]
19
20extern "C" {
21 #[linkage = "extern_weak"]
22 static foo: i8;
23}
24```
25
26The following declarations are valid:
27
28```
29#![feature(linkage)]
30
31extern "C" {
32 #[linkage = "extern_weak"]
33 static foo: Option<unsafe extern "C" fn()>;
34
35 #[linkage = "extern_weak"]
36 static bar: Option<&'static i8>;
37
38 #[linkage = "extern_weak"]
39 static baz: *mut i8;
40}
41```