@@ -1653,14 +1653,43 @@ the Rust ABI and the foreign ABI.
1653
1653
A number of [ attributes] ( #ffi-attributes ) control the behavior of external blocks.
1654
1654
1655
1655
By default external blocks assume that the library they are calling uses the
1656
- standard C "cdecl" ABI. Other ABIs may be specified using an ` abi ` string, as
1657
- shown here:
1656
+ standard C ABI on the specific platform . Other ABIs may be specified using an
1657
+ ` abi ` string, as shown here:
1658
1658
1659
1659
``` ignore
1660
1660
// Interface to the Windows API
1661
1661
extern "stdcall" { }
1662
1662
```
1663
1663
1664
+ There are three ABI strings which are cross-platform, and which all compilers
1665
+ are guaranteed to support:
1666
+
1667
+ * ` extern "Rust" ` -- The default ABI when you write a normal ` fn foo() ` in any
1668
+ Rust code.
1669
+ * ` extern "C" ` -- This is the same as ` extern fn foo() ` ; whatever the default
1670
+ your C compiler supports.
1671
+ * ` extern "system" ` -- Usually the same as ` extern "C" ` , except on Win32, in
1672
+ which case it's ` "stdcall" ` , or what you should use to link to the Windows API
1673
+ itself
1674
+
1675
+ There are also some platform-specific ABI strings:
1676
+
1677
+ * ` extern "cdecl" ` -- The default for x86\_ 32 C code.
1678
+ * ` extern "stdcall" ` -- The default for the Win32 API on x86\_ 32.
1679
+ * ` extern "win64" ` -- The default for C code on x86\_ 64 Windows.
1680
+ * ` extern "aapcs" ` -- The default for ARM.
1681
+ * ` extern "fastcall" ` -- The ` fastcall ` ABI -- corresponds to MSVC's
1682
+ ` __fastcall ` and GCC and clang's ` __attribute__((fastcall)) `
1683
+ * ` extern "vectorcall" ` -- The ` vectorcall ` ABI -- corresponds to MSVC's
1684
+ ` __vectorcall ` and clang's ` __attribute__((vectorcall)) `
1685
+
1686
+ Finally, there are some rustc-specific ABI strings:
1687
+
1688
+ * ` extern "rust-intrinsic" ` -- The ABI of rustc intrinsics.
1689
+ * ` extern "rust-call" ` -- The ABI of the Fn::call trait functions.
1690
+ * ` extern "platform-intrinsic" ` -- Specific platform intrinsics -- like, for
1691
+ example, ` sqrt ` -- have this ABI. You should never have to deal with it.
1692
+
1664
1693
The ` link ` attribute allows the name of the library to be specified. When
1665
1694
specified the compiler will attempt to link against the native library of the
1666
1695
specified name.
0 commit comments