rustbindgen

Bindgen skipping definitions from C++ header file


I am trying to compile bindings for the SEAL C++ library. Here is my repo.

// Generate the bindings
let bindings = bindgen::Builder::default()
    .generate_inline_functions(true)
    .derive_default(true)
    .header("./seal/src/seal/seal.h")
    .clang_arg("-I./seal/src/")
    .clang_arg("-std=c++17")
    .clang_arg("-x")
    .clang_arg("c++")
    .opaque_type("std::.*")
    .whitelist_type("seal::.*")
    .generate()
    .expect("Unable to generate bindings");

let out_path = PathBuf::from("./src/");
bindings
    .write_to_file(out_path.join("bindings.rs"))
    .expect("Couldn't write bindings!");

bindings.rs does not have anything from defaultparams.h

What do I have to add to the Builder object to include defaultparams.h's functions in the generated bindings? I need coeff_modulus_128() for example.

I tried whitelisting the std::vector but it did not have any impact on the generated bindings.


Solution

  • Solved by adding .whitelist_function("seal::.*") to the build.rs file. Since the inline functions weren't enclosed in a type, they were not whitelisted by the current config.