cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

with_language option in builder is not working as expected

Open beqabeqa473 opened this issue 2 years ago • 1 comments

Hello.

I am trying to generate a C header using cbindgen, using build.rs builder.

here is a code

use std::env;

fn main() {
    println!("cargo:rerun-if-changed=./src/lib.rs");

    let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

    cbindgen::Builder::new()
        .with_crate(crate_dir)
        .with_include_version(true)
        .with_documentation(false)
        .with_parse_deps(true)
        .with_parse_include(&["ffi-support", "opaque-pointer"])
        .with_cpp_compat(true)
        // .with_language(cbindgen::Language::C)
        .generate()
        .expect("Unable to generate bindings")
        .write_to_file("header.h");
}

It still generates C++ header file. Used crate is 0.26.0

Is something wrong with builder itself or maybe i am doing something wrong?

Thanks.

beqabeqa473 avatar Nov 22 '23 07:11 beqabeqa473

Sorry for the lag replying to this. You're using with_cpp_compat(true) which generates C++-compatible code, is that not what's going on?

emilio avatar Apr 15 '24 00:04 emilio