Skip to content

Duplicate definitions with forward declared pointer types #1864

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

Open
7Hazard opened this issue Aug 9, 2020 · 1 comment
Open

Duplicate definitions with forward declared pointer types #1864

7Hazard opened this issue Aug 9, 2020 · 1 comment

Comments

@7Hazard
Copy link

7Hazard commented Aug 9, 2020

Input C/C++ Header

CAPI void alt_RotationLayout_CAPI_Free_Forward(struct alt_RotationLayout* ptr);
typedef struct alt_RotationLayout {
    float roll;
    float pitch;
    float yaw;
} alt_RotationLayout;
CAPI void alt_RotationLayout_CAPI_Free(struct alt_RotationLayout* ptr);

Bindgen Invocation

let bindings = bindgen::Builder::default()
        .rustfmt_bindings(true)
        .layout_tests(false)
        .header(format!("./altv-capi-{}-static-{}/include/altv-capi-{}.h", kind, platform, kind))
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .expect("Unable to generate bindings");

    bindings
        .write_to_file(format!("src/altv_{}.rs", kind))
        .expect("Couldn't write bindings!");

Actual Results

/* automatically generated by rust-bindgen 0.54.1 */

pub const true_: u32 = 1;
pub const false_: u32 = 0;
pub const __bool_true_false_are_defined: u32 = 1;
pub type nullptr_t = *mut ::std::os::raw::c_void;
extern "C" {
  pub fn alt_RotationLayout_CAPI_Free_Forward(ptr: *mut alt_RotationLayout);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct alt_RotationLayout {
  pub roll: f32,
  pub pitch: f32,
  pub yaw: f32,
}
extern "C" {
  pub fn alt_RotationLayout_CAPI_Free(ptr: *mut alt_RotationLayout);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct alt_RotationLayout {
  pub _address: u8,
}

Expected Results

No duplicate definitions (when using forward declared pointers).

/* automatically generated by rust-bindgen 0.54.1 */

pub const true_: u32 = 1;
pub const false_: u32 = 0;
pub const __bool_true_false_are_defined: u32 = 1;
pub type nullptr_t = *mut ::std::os::raw::c_void;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
extern "C" {
  pub fn alt_RotationLayout_CAPI_Free_Forward(ptr: *mut alt_RotationLayout);
}
pub struct alt_RotationLayout {
  pub roll: f32,
  pub pitch: f32,
  pub yaw: f32,
}
extern "C" {
  pub fn alt_RotationLayout_CAPI_Free(ptr: *mut alt_RotationLayout);
}
@pvdrz
Copy link
Contributor

pvdrz commented Sep 21, 2022

Isn't this somewhat related to #2227 ?

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

Successfully merging a pull request may close this issue.

2 participants