Skip to content

Commit

Permalink
No longer need to hack around linking to the standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Feb 4, 2020
1 parent 24b1ea0 commit 8ce242d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
5 changes: 0 additions & 5 deletions examples/integers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@
pub extern "C" fn addition(a: u32, b: u32) -> u32 {
a + b
}

#[allow(dead_code)]
pub extern "C" fn fix_linking_when_not_using_stdlib() {
panic!()
}
5 changes: 0 additions & 5 deletions examples/tuples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ impl From<Tuple> for (u32, u32) {
pub extern "C" fn flip_things_around(tup: Tuple) -> Tuple {
flip_things_around_rust(tup.into()).into()
}

#[allow(dead_code)]
pub extern "C" fn fix_linking_when_not_using_stdlib() {
panic!()
}
5 changes: 0 additions & 5 deletions examples/vector_return/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,3 @@ pub extern "C" fn counter_free(arr: *mut i16, size: size_t) {
Vec::from_raw_parts(arr, size, size)
};
}

#[allow(dead_code)]
pub extern "C" fn fix_linking_when_not_using_stdlib() {
panic!()
}
9 changes: 0 additions & 9 deletions site/basics/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ was [implemented in Rust 1.10][rust-1.10]; if you are using earlier
versions, it is encouraged that you upgrade, but you can also use
`dylib` with minimal ill effects.

Some examples are so minimal that they don't use any features from the
Rust standard library. This triggers a [known issue][rust-18807] and
linking will fail. The only workaround is to include an exported but
unused function that does use something from the standard
library. These functions are called
`fix_linking_when_not_using_stdlib` and can be safely removed for any
larger project.

## C

All C examples will be compiled using the C11 standard.
Expand Down Expand Up @@ -93,7 +85,6 @@ installed.
[dyn-stat]: https://doc.rust-lang.org/cargo/reference/manifest.html#building-dynamic-or-static-libraries
[rfc1510]: https://github.com/rust-lang/rfcs/blob/master/text/1510-cdylib.md
[rust-1.10]: https://blog.rust-lang.org/2016/07/07/Rust-1.10.html
[rust-18807]: https://github.com/rust-lang/rust/issues/18807
[gem]: https://github.com/ffi/ffi
[ctypes]: https://docs.python.org/3/library/ctypes.html
[node-ffi]: https://www.npmjs.com/package/ffi-napi
Expand Down

0 comments on commit 8ce242d

Please sign in to comment.