Skip to content

Update FFI signature table to use pipe format #13758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/doc/complement-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ let _ = close(Door::<Closed>("front".to_owned())); // error: mismatched types: e

## C function signature conversions

Description C signature Equivalent Rust signature
---------------------- ---------------------------------------------- ------------------------------------------
no parameters `void foo(void);` `fn foo();`
return value `int foo(void);` `fn foo() -> c_int;`
function parameters `void foo(int x, int y);` `fn foo(x: c_int, y: c_int);`
in-out pointers `void foo(const int* in_ptr, int* out_ptr);` `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);`
| Description | C signature | Equivalent Rust signature |
|---------------------|-----------------------------------------------|------------------------------------------------|
| no parameters | `void foo(void);` | `fn foo();` |
| return value | `int foo(void);` | `fn foo() -> c_int;` |
| function parameters | `void foo(int x, int y);` | `fn foo(x: c_int, y: c_int);` |
| in-out pointers | `void foo(const int* in_ptr, int* out_ptr);` | `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);` |

Note: The Rust signatures should be wrapped in an `extern "ABI" { ... }` block.

Expand Down