我正在尝试将 *.cc 链接到 Rust。
构建.rs:
fn main() {
cc::Build::new()
.file("src/bindings.cc")
.cargo_metadata(true)
.cpp(true)
.compile("bindings");
}
Run Code Online (Sandbox Code Playgroud)
绑定.cc:
extern "C" {
leveldb::Status db_get(
LevelDB* db,
const char* key, size_t keylen,
const char** val, size_t* vallen,
bool fillCache
) {
printf("0: %p, 1: %p, 2: %d, 3: %p, 4: %p, 5: %s\n",
db,
key, keylen,
val, vallen,
fillCache ? "true" : "false"
);
leveldb::Status status;
return status;
}
}
Run Code Online (Sandbox Code Playgroud)
系统.rs:
enum LevelDB {}
// why? leveldb::Status has private property const char*
// It doesnt …Run Code Online (Sandbox Code Playgroud)