Skip to content

type is redefined #2571

Open
Open
@alexcwyu

Description

@alexcwyu

Input C/C++ Header

Header

#include "AeronArchive.h"

the actual header can be found here
https://github.com/real-logic/aeron/blob/1.41.4/aeron-archive/src/main/cpp/client/AeronArchive.h

Bindgen Invocation

bindgen code

    println!("cargo:rerun-if-changed=build.rs");
    println!("cargo:rerun-if-changed=bindings.h");

    let aeron_path = canonicalize(Path::new("./aeron")).unwrap();
    let header_path = aeron_path.join("aeron-archive/src/main/cpp/client");
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());

    let cmake_output = Config::new(&aeron_path)
        .build();

    let base_lib_dir = cmake_output.join("build");
    println!(
        "cargo:rustc-link-search=native={}",
        base_lib_dir.join("lib").display()
    );
    // Because the `cmake_output` path is different for debug/release, we're not worried
    // about accidentally linking the Debug library when this is a release build or vice-versa
    println!(
        "cargo:rustc-link-search=native={}",
        base_lib_dir.join("lib/Debug").display()
    );
    println!(
        "cargo:rustc-link-search=native={}",
        base_lib_dir.join("binaries/Debug").display()
    );
    println!(
        "cargo:rustc-link-search=native={}",
        base_lib_dir.join("lib/Release").display()
    );
    println!(
        "cargo:rustc-link-search=native={}",
        base_lib_dir.join("binaries/Release").display()
    );

    println!("cargo:rustc-link-lib=static=aeron_archive_client");
    println!("cargo:rustc-link-lib=static=aeron_archive_client_wrapper");
    println!("cargo:rustc-link-lib=stdc++");

    println!("cargo:include={}", header_path.display());
    let bindings = bindgen::Builder::default()
        .clang_arg(format!("-I{}", header_path.display()))
        .clang_arg(format!(
            "-I{}",
            aeron_path.join("aeron-client/src/main/c").display()
        ))
        .header("bindings.h")
        .enable_cxx_namespaces()
        // enable C++
        .clang_args(&["-x", "c++", "--std=c++14"])
        .opaque_type("std::.*")
        .constified_enum_module("aeron_.*_enum")
        .derive_debug(false)
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .expect("Unable to generate aeron bindings");

    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings!");

Actual Results

error

error[E0428]: the name `this_t` is defined multiple times
     --> /home/alex/workspaces/personal/aeron-lib/target/debug/build/libaeron_archive-sys-0a7352ee9f461a4a/out/bindings.rs:10595:5
      |
10115 |     pub type this_t = root::aeron::concurrent::logbuffer::BufferClaim;
      |     ------------------------------------------------------------------ previous definition of the type `this_t` here
...
10595 |     pub type this_t = root::aeron::ChannelUri;
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `this_t` redefined here
      |
      = note: `this_t` must be defined only once in the type namespace of this module

error[E0428]: the name `this_t` is defined multiple times
     --> /home/alex/workspaces/personal/aeron-lib/target/debug/build/libaeron_archive-sys-0a7352ee9f461a4a/out/bindings.rs:10597:5
      |
10115 |     pub type this_t = root::aeron::concurrent::logbuffer::BufferClaim;
      |     ------------------------------------------------------------------ previous definition of the type `this_t` here
...
10597 |     pub type this_t = root::aeron::archive::client::Context;
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `this_t` redefined here
      |
      = note: `this_t` must be defined only once in the type namespace of this module

error[E0428]: the name `this_t` is defined multiple times
     --> /home/alex/workspaces/personal/aeron-lib/target/debug/build/libaeron_archive-sys-0a7352ee9f461a4a/out/bindings.rs:10598:5
      |
10115 |     pub type this_t = root::aeron::concurrent::logbuffer::BufferClaim;
      |     ------------------------------------------------------------------ previous definition of the type `this_t` here
...
10598 |     pub type this_t = root::aeron::BufferBuilder;
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `this_t` redefined here
      |
      = note: `this_t` must be defined only once in the type namespace of this module

generated file

// skip other line....
    pub type this_t = root::aeron::ChannelUri;
    pub type this_t = root::aeron::archive::client::Context;
    pub type this_t = root::aeron::BufferBuilder;
}

Expected Results

no redefined type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions