Skip to content

Commit 55c703d

Browse files
committed
More clearly define the default abi of an extern block
This attempts to make it clearer that if the ABI string is not specified, it defaults to the "C" ABI. I felt like the existing text didn't emphasize that enough. I also took the opportunity to reword the intro to more generally explain what the ABI string does. A followup PR will further clarify some of the confusing use of the word "default" in the specific ABI definitions.
1 parent d01f991 commit 55c703d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/items/external-blocks.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@ r[items.extern.abi]
9898
## ABI
9999

100100
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 <abbr title="application binary interface">ABI</abbr> 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.
104102

105-
```rust
106-
// Interface to the Windows API
107-
unsafe extern "system" { }
108-
```
103+
> [!EXAMPLE]
104+
> ```rust
105+
> // Interface to the Windows API
106+
> unsafe extern "system" { }
107+
> ```
108+
109+
r[iterms.extern.abi.default]
110+
If the ABI string is not specified, it defaults to `"C"`.
111+
112+
> [!NOTE]
113+
> It is recommended to always specify the ABI to make it clear which ABI is used. Future versions of Rust may make this a requirement, see [#134986](https://github.com/rust-lang/rust/issues/134986).
109114
110115
r[items.extern.abi.standard]
111116
The following ABI strings are supported on all platforms:

0 commit comments

Comments
 (0)