You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/glossary.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,14 @@ The alignment of a value specifies what addresses values are preferred to
11
11
start at. Always a power of two. References to a value must be aligned.
12
12
[More][alignment].
13
13
14
+
r[glossary.abi]
15
+
### Application binary interface (ABI)
16
+
17
+
An *application binary interface* (ABI) defines how compiled code interacts with other compiled code. With [`extern` blocks] and [`extern fn`], *ABI strings* affect:
18
+
19
+
-**Calling convention**: How function arguments are passed, values are returned (e.g., in registers or on the stack), and who is responsible for cleaning up the stack.
20
+
-**Unwinding**: Whether stack unwinding is allowed. For example, the `"C-unwind"` ABI allows unwinding across the FFI boundary, while the `"C"` ABI does not.
21
+
14
22
### Arity
15
23
16
24
Arity refers to the number of arguments a function or operator takes.
@@ -287,6 +295,8 @@ uninhabited type is "empty" in the sense that there are no values of the type. T
287
295
example of an uninhabited type is the [never type]`!`, or an enum with no variants
288
296
`enum Never { }`. Opposite of [Inhabited](#inhabited).
Copy file name to clipboardExpand all lines: src/items/external-blocks.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,14 +98,21 @@ r[items.extern.abi]
98
98
## ABI
99
99
100
100
r[items.extern.abi.intro]
101
-
By default external blocks assume that the library they are calling uses the
102
-
standard C ABI on the specific platform. Other ABIs may be specified using an
103
-
`abi` string, as shown here:
101
+
The `extern` keyword can be followed by an optional [ABI] string. The ABI specifies the calling convention of the functions in the block. The calling convention defines a low-level interface for functions, such as how arguments are placed in registers or on the stack, how return values are passed, and who is responsible for cleaning up the stack.
104
102
105
-
```rust
106
-
// Interface to the Windows API
107
-
unsafeextern"system" { }
108
-
```
103
+
> [!EXAMPLE]
104
+
> ```rust
105
+
> // Interface to the Windows API.
106
+
> unsafeextern"system" { /* ... */ }
107
+
> ```
108
+
109
+
r[items.extern.abi.default]
110
+
IftheABIstringisnotspecified, itdefaultsto `"C"`.
111
+
112
+
> [!NOTE]
113
+
> The `extern` syntaxwithoutanexplicitABIisbeingphasedout, soit'sbettertoalwayswritetheABIexplicitly.
114
+
>
115
+
> Formoredetails, see [Rustissue #134986](https://github.com/rust-lang/rust/issues/134986).
0 commit comments