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/abi.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -256,21 +256,21 @@ r[abi.symbol-name.names]
256
256
The *`export_name` attribute* shall only be applied to a `static` or `fn` item. The *`export_name` attribute* shall not be applied to an item declared within an [`extern` block].
257
257
258
258
```rust
259
-
#[no_mangle]
259
+
#[unsafe(no_mangle(]
260
260
extern"C"fnfoo(x:i32) ->i32 {
261
261
x+1
262
262
}
263
263
264
-
#[export_name ="bar"]
264
+
#[unsafe(export_name ="bar")]
265
265
extern"C"fnbaz(x:i32) ->i32 {
266
266
x+2
267
267
}
268
268
```
269
269
270
270
```rust,compile_fail
271
-
extern "C" {
272
-
#[export_name = "foo"]
273
-
fn __foo(x: i32) -> i32; // error: not a free function, impl method, or static
271
+
unsafe extern "C" {
272
+
#[unsafe(export_name = "foo")]
273
+
unsafe fn __foo(x: i32) -> i32; // error: not a free function, impl method, or static
The *`no_mangle` attribute* may be specified as a built-in attribute, using the [_MetaWord_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the declaration name of the item.
The *`export_name` attribute* may be specified as a built-in attribute, using the [_MetaNameValueStr_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the content of `STRING_LITERAL`.
0 commit comments