mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.29k stars 294 forks source link

with_language option in builder is not working as expected #902

Open beqabeqa473 opened 7 months ago

beqabeqa473 commented 7 months ago

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.

emilio commented 3 months ago

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?