Using .c source files with Rust

前端 未结 2 1151
-上瘾入骨i
-上瘾入骨i 2020-12-06 11:33

Is there a standard way to include .c source files?

So far I\'ve been using extern \"C\" { ... } to expose the functions, compiling .c to an object file

2条回答
  •  死守一世寂寞
    2020-12-06 12:07

    Editor's note: This answer predates Rust 1.0 and is no longer applicable.

    Luqman gave a hint on IRC; using extern "C" { ... } with #[link_args="src/source.c"]; in the crate file works for me.

提交回复
热议问题