Skip to content

Commit 8c57c4e

Browse files
authored
Merge pull request #193 from amosonn/patch-2
Fix example in FFI section Calling Rust from C
2 parents ae9b87f + 6e93a7c commit 8c57c4e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,13 @@ fairly easy, but requires a few things:
662662
663663
```rust
664664
#[no_mangle]
665-
pub extern fn hello_rust() -> *const u8 {
665+
pub extern "C" fn hello_rust() -> *const u8 {
666666
"Hello, world!\0".as_ptr()
667667
}
668668
# fn main() {}
669669
```
670670

671-
The `extern` makes this function adhere to the C calling convention, as
671+
The `extern "C"` makes this function adhere to the C calling convention, as
672672
discussed above in "[Foreign Calling
673673
Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle`
674674
attribute turns off Rust's name mangling, so that it is easier to link to.

0 commit comments

Comments
 (0)