Skip to content
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

你是如何生成 vtable 的? #3

Closed
linonetwo opened this issue Mar 14, 2024 · 1 comment
Closed

你是如何生成 vtable 的? #3

linonetwo opened this issue Mar 14, 2024 · 1 comment

Comments

@linonetwo
Copy link

bindgen 自动生成的 bindgen_vtable 是空的,rust-lang/rust-bindgen#27

比如我生成的是

#[repr(C)]
pub struct YDQueryResult__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug)]
pub struct YDQueryResult {
    pub vtable_: *const YDQueryResult__bindgen_vtable,
}

你是如何正常生成 CThostFtdcTraderApi__bindgen_vtable 的呢?

@linonetwo
Copy link
Author

    let bindings = bindgen::Builder::default()
        .header("wrapper.hpp")
        .clang_arg("-x")
        .clang_arg("c++")
        .clang_arg("-std=c++11")
        .derive_default(true)
        .derive_debug(true)
        .vtable_generation(true)
        .generate_comments(false) // 不需形成doc ,默认true
        .layout_tests(false) //不需要test,默认true
        .generate_comments(false) //不需注释,默认true
        .derive_copy(true)
        .derive_hash(false) //不要实现hash
        .parse_callbacks(Box::new(MyCallback {}))
        .generate()
        .expect("Unable to generate bindings");

我之前是让 gpt 写的这段,它缺了 .vtable_generation(true),参考你的加上即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant