Closed
Description
In chapter 9.1 "A little C with your Rust", the extern "C"
function is declared with
pub extern "C" fn cool_function(
i: cty::c_int,
c: cty::c_char,
cs: *mut CoolStruct
);
I was not able to successfully build my project with such a declaration, I always ended up having "free function without a body" errors. After having compared this approach with several other sources, it seems to me that the only correct way to declare this function would be
extern "C" {
fn cool_function(
i: cty::c_int,
c: cty::c_char,
cs: *mut CoolStruct
);
}
The pub extern "C" fn ...
syntax only seems to be valid to expose Rust's functions.
Please correct me if I'm wrong.
Furthermore, the #[link(name = "<library-name>")]
could be prepended, possibly with a reference to further documentation.
Metadata
Metadata
Assignees
Labels
No labels