Closed
Description
Input C/C++ Header
#define spectre_enum(_type, _name) _type _name; enum _name
typedef spectre_enum( unsigned int, SpectreAlgorithm ) {
/** (2012-03-05) V0 incorrectly performed host-endian math with bytes translated into 16-bit network-endian. */
SpectreAlgorithmV0,
/** (2012-07-17) V1 incorrectly sized site name fields by character count rather than byte count. */
SpectreAlgorithmV1,
/** (2014-09-24) V2 incorrectly sized user name fields by character count rather than byte count. */
SpectreAlgorithmV2,
/** (2015-01-15) V3 is the current version. */
SpectreAlgorithmV3,
SpectreAlgorithmCurrent = SpectreAlgorithmV3,
SpectreAlgorithmFirst = SpectreAlgorithmV0,
SpectreAlgorithmLast = SpectreAlgorithmV3,
};
Bindgen Invocation
Builder command:
let bindings = bindgen::Builder::default()
.header("src/spectre/api/c/spectre-types.h")
.header("src/spectre/api/c/spectre-marshal.h")
.header("src/spectre/api/c/spectre-algorithm.h")
// .constified_enum_module("*")
.rustfmt_bindings(true)
.generate()
.expect("Unable to generate bindings");
Actual Results
Produced bindings.rs
pub type SpectreAlgorithm = ::std::os::raw::c_uint; // <<<<<< HERE
#[doc = " (2012-03-05) V0 incorrectly performed host-endian math with bytes translated into 16-bit network-endian."]
pub const SpectreAlgorithm_SpectreAlgorithmV0: SpectreAlgorithm = 0;
#[doc = " (2012-07-17) V1 incorrectly sized site name fields by character count rather than byte count."]
pub const SpectreAlgorithm_SpectreAlgorithmV1: SpectreAlgorithm = 1;
#[doc = " (2014-09-24) V2 incorrectly sized user name fields by character count rather than byte count."]
pub const SpectreAlgorithm_SpectreAlgorithmV2: SpectreAlgorithm = 2;
#[doc = " (2015-01-15) V3 is the current version."]
pub const SpectreAlgorithm_SpectreAlgorithmV3: SpectreAlgorithm = 3;
#[doc = " (2015-01-15) V3 is the current version."]
pub const SpectreAlgorithm_SpectreAlgorithmCurrent: SpectreAlgorithm = 3;
#[doc = " (2015-01-15) V3 is the current version."]
pub const SpectreAlgorithm_SpectreAlgorithmFirst: SpectreAlgorithm = 0;
#[doc = " (2015-01-15) V3 is the current version."]
pub const SpectreAlgorithm_SpectreAlgorithmLast: SpectreAlgorithm = 3;
#[doc = " Types."]
pub type SpectreAlgorithm = ::std::os::raw::c_uint; // <<<<<< and HERE
Error from cargo:
error[E0428]: the name `SpectreAlgorithm` is defined multiple times
--> /home/timo/Projects/rust-gtk-mpw/target/debug/build/rust-mpw-a3a9037bf1230854/out/spectre_bindings.rs:2327:1
|
2311 | pub type SpectreAlgorithm = ::std::os::raw::c_uint;
| --------------------------------------------------- previous definition of the type `SpectreAlgorithm` here
...
2327 | pub type SpectreAlgorithm = ::std::os::raw::c_uint;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SpectreAlgorithm` redefined here
|
= note: `SpectreAlgorithm` must be defined only once in the type namespace of this module
Expected Results
The bindgen should just irgnore the duplicate definition of the SpectreAlgorithm
type. In c the enum and the integer are used for easier function signatures.